原创 Setup Apache2+Php5+Mysql+Cakep...

在Ubuntu上安装LAMP server,官方网站其实有一篇(http://help.ubuntu.com/community/ApacheMySQLPHP)已经讲的比较全了,这里只是把大概的步骤摘抄一下,以及添加一些cakephp相关的配置而已。
1. Apache2
sudo apt-get install apache2
本次安装的版本是apache2.2-bin 2.2.14-5ubuntu8, 安装后访问http://localhost应该可以看到It works!的字样
2. PHP5
sudo apt-get install php5 sudo /etc/init.d/apache2 restart
安装了php5 5.3.2-1ubuntu4.2,它会自动安装对应的apache2 mod版本:libapache2-mod-php5 5.3.2-1ubuntu4.2,安装后可以做一个phpinfo的测试页面试试看,缺省网站根路径在/var/www,因此在该目录下添加一个内容为<?php phpinfo(); ?>的info.php文件,访问http://localhost/info.php测试看php是否已经架设好。
3. Mysql5
sudo apt-get install mysql-server
安装的版本是mysql-server-5.1 5.1.41-3ubuntu12.3
安装php5-mysql的extension:
sudo apt-get install php5-mysqlsudo /etc/init.d/apache2 restart
这时它应该会在/etc/php5/conf.d下面添加了mysql.ini,设置装载进mysql.so,重启后查看info.php,mysql模块应该正常工作。
用户和数据库创建
mysql> CREATE DATABASE database1;mysql> GRANT ALL PRIVILEGES ON database1.* TO 'yourusername'@'localhost' IDENTIFIED BY 'yourpassword' WITH GRANT OPTION;
数据导入部分掠过。。
4. Cakephp
i) 到http://cakephp.org/下载tar包,我下的版本是1.3.2
ii)解压到根目录
mv cakephp-cakephp-1.3.2-51-g4c27c24.tar.gz /var/www/sudo tar -xvf cakephp-cakephp-1.3.2-51-g4c27c24.tar.gzmv cakephp-g4c27c24 cakephp
iii) 更改tmp目录权限
sudo chmod -R 777 cakephp/app/tmp
iv)打开rewrite模块
sudo a2enmod rewrite
v) 修改apache config /etc/apache2/sites-enabled/000-default,允许覆盖设定(AllowOverride设置为All):
<Directory /var/www/> Options Indexes FollowSymLinks MultiViews AllowOverride All Order allow,deny allow from all </Directory>
vi)最后重启apache
sudo /etc/init.d/apache2 restart
安装后查看http://localhost/cakephp/,一般这时候会有两个warnning
Notice (1024): Please change the value of 'Security.salt' in app/config/core.php to a salt value specific to your application [CORE/cake/libs/debugger.php, line 684]
Notice (1024): Please change the value of 'Security.cipherSeed' in app/config/core.php to a numeric (digits only) seed value specific to your application [CORE/cake/libs/debugger.php, line 688]
在core.php配置文件中更改一下Security.salt和SecuritycipherSeed的缺省值就可以了。
另外设置一下数据库连接
cp app/config/database.config.default app/config/database.configvi app/config/database.config
修改一下连接参数,保存后再刷新http://localhost/cakephp/,这时候应该没有问题了:
Your tmp directory is writable.
The FileEngine is being used for caching. To change the config edit APP/config/core.php
Your database configuration file is present.
Cake is able to connect to the database.
6. 可选安装:phpmyadmin
安装phpmyadmin很简单,执行
sudo apt-get install phpmyadmin
然后根据提示完成安装就可以了,访问http://localhost/phpmyadmin使用数据库帐户登录。
Tags: 

延伸阅读

最新评论

发表评论