在Linux上装nginx(Linux分为Ubuntu和centos,centos系用的yum,Ubuntu用的apt安装软件)
sudo apt-get update
sudo apt-get install nginx
安装php5.6
apt-add-repository ppa:ondrej/php //增加源
apt-get update //更新apt-get
apt-get install php5.6 php5.6-fpm //安装php5.6和对应的fpm
管理器
安装MySQL
sudo apt-get install mysql-server
安装过程中要输入MySQL登陆密码
配置php
nginx -t //检测nginx配置
cat /etc/nginx/nginx.conf中找/etc/nginx/sites-enabled/分配置cd进入分配置ls查看文件'default'cat查看default里面nginx根目录'/var/www/html'
进入nginx根目录写入:
<?php
phpinfo();
?>
适配php
sudo vim /etc/nginx/sites-available/default
改动为 location ~ .php$ {
try_files $udri =404;
fastcgi_split_path_info ^(.+\.php)(/.+)$;
fastcgi_pass unix:/var/run/php/php5.6-fpm.sock;
fastcgi_index index.php;
fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
include fastcgi_params;
(把原来location下的配置文件按两下DD删除把locattion前面的#号按X删除在把上面配置文件写进去)
重启nginx
nginx -s reload
浏览器输入你的ip地址既可以查看 php配置在ip地址后加上“文件名”.php