$ sudo apt-get update $ sudo apt-get install nginx
root@ubuntu:~# nginx -v nginx version: nginx/1.12.1 (Ubuntu)
$ sudo apt-get install python-software-properties software-properties-common $ sudo add-apt-repository ppa:ondrej/php $ sudo apt-get update
$ sudo apt-get install php5.6-fpm php5.6-mysql php5.6-common php5.6-curl php5.6-cli php5.6-mcrypt php5.6-mbstring php5.6-dom
vim /etc/php/5.6/fpm/pool.d/www.conf #增長用戶和用戶組 user = www-data group = www-data #去掉前面的分號 security.limit_extensions = .php .php3 .php4 .php5
$ sudo apt-get install mysql-server mysql-client
途中會提示設置MySQL的密碼,安裝好後:php
$ mysql -uroot -p
而後輸入剛剛設置的密碼,能成功進入即成功安裝。html
新建一個文件夾 /etc/nginx/vhost,同時建一個文件domain.confpython
mkdir /etc/nginx/vhost && touch /etc/nginx/vhost/domain.conf
打開文件配置內容mysql
vim domain.conf server{ listen 80; server_name www.beixuan.com;#根據本身的域名配置 root /var/www/html/jishuge;#根據本身的根目錄配置 location / { try_files $uri $uri/ /index.php?$query_string; index index.html index.htm index.php l.php; autoindex off; } location ~ \.php(.*)$ { fastcgi_pass 127.0.0.1:9000; fastcgi_index index.php; fastcgi_split_path_info ^((?U).+\.php)(/?.+)$; fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name; fastcgi_param PATH_INFO $fastcgi_path_info; fastcgi_param PATH_TRANSLATED $document_root$fastcgi_path_info; include fastcgi_params; } access_log /var/www/html/jishuge/log/access.log;#配置訪問日誌 error_log /var/www/html/jishuge/log/error.log;#配置錯誤日誌 }
在nginx.conf文件中引入配置文件nginx
include /etc/nginx/vhost/*.conf;
重啓nginx 和php-fpmsql
#第一: listen = /run/php/php5.6-fpm.sock #修改爲下面內容 listen =127.0.0.1:9000 #第二: security.limit_extensions = .php .php3 .php4 .php5 #去掉前面的分號
打開php.ini配置文件apache
#找到cgi.fix_pathinfo選項,去掉註釋;,而後將值設置爲1: cgi.fix_pathinfo = 1;