1.安装mysql
sudo apt-get install mysql-server mysql-client
过程输入用户名和密码
1.安装nginx
sudo apt-get install nginx
2.使用php5-fpm来作为我们的php解析
sudo apt-get install php5-fpm
3.修改一下nginx配置,使之支持php
$vim /etc/nginx/sites-available/default
server {
listen 80 default_server;
listen [::]:80 default_server ipv6only=on;
root /usr/share/nginx/html;
index index.php index.html index.htm;
server_name localhost;
location ~ \.php$ {
fastcgi_pass unix:/var/run/php5-fpm.sock;
fastcgi_index index.php;
include fastcgi_params;
}
}
即因为ubuntu的对php监听端口修改了
修改 location ~ \.php$ {
fastcgi_pass 127.0.0.1:9000;
fastcgi_index index.php;
fastcgi_param APPLICATION_ENV production;
include fastcgi_params;
}
为
location ~ \.php$ {
fastcgi_pass unix:/var/run/php5-fpm.sock;
fastcgi_index index.php;
include fastcgi_params;
}
要修改php文件存放目录,把所有的root 后的路径改为自己要的路径
测试配置修改是否成功 sudo nginx -t
5.重启服务
sudo service php5-fpm restart
sudo service nginx restart
6.测试
在/usr/share/nginx/html/目录下
rm index.html
vim index.php
<?php
phpinfo();
?>
在浏览器里输入127.0.0.1,出现如下界面则成功
7.添加扩张包(如php5-mcrypt )
a.命令行下载(不嫌麻烦可以到网上找安装包,用源码安装)
sudo apt-get install php5-mcrypt
b.查看是否安装成功
find / -name mcrypt.so
c.修改配置文件php.ini vim /etc/php5/fpm/php.ini
加入: extension=mcrypt.so
d.重启服务
sudo service php5-fpm restart sudo service nginx restart