ubuntu下安装php环境
sudo gedit /etc/php5/apache2/php.ini
允许 mysql 和 gd 模块,检查文件最后是否包含下面的代码,如果没有添加上。(默认是在配置文件最后有添加的,检查一下以防万一)
extension=mysql.soextension=gd.so3.
b). 配置Apache
sudo gedit /etc/apache2/apache2.conf
b). 配置 mysql,让它支持其它客户端访问,如果你不需要就不用修改。
sudo gedit /etc/mysql/my.cnf
查找文件:skip-networking
修改为:#skip-networking
保存并关闭文件。
重新启动 mysql
sudo /etc/init.d/mysql restart
3. 运行、停止和重启Apache服务
sudo /usr/sbin/apache2ctl start
sudo /usr/sbin/apache2ctl stop
sudo /usr/sbin/apache2ctl restart
4. 测试
为检查你的PHP安装状态,新建PHP文件:
sudo gedit /var/www/test.php
在上述文件中插入下面这行代码:
在Web浏览器中查看此页面,通过 http://localhost/testphp.php 或者其他
测试函数
<?php
// Show all information, defaults to INFO_ALL
phpinfo ();
// Show just the module information.
// phpinfo(8) yields identical results.
phpinfo ( INFO_MODULES );
?>
在/var/www 下建立测试页面
chown -R mlzboy ./www
chmod -R 777 ./www
touch test.php
<?php
phpinof();
?>