1.安裝前準備:
1.1.卸載NGINX
sudo apt-get remove nginx nginx-common # 卸載刪除除了配置文件以外的所有文件。
sudo apt-get purge nginx nginx-common # 卸載所有東東,包括刪除配置文件。
sudo apt-get autoremove # 在上面命令結(jié)束后執(zhí)行,主要是卸載刪除Nginx的不再被使用的依賴包。
sudo apt-get remove nginx-full nginx-common #卸載刪除兩個主要的包。
sudo service nginx restart #重啟nginx
ps aux|grep nginx
1.2.卸載PHP
#卸載PHP5.X
sudo apt-get --purge remove php5* libapache2-mod-php5
sudo apt-get autoremove php5
運行安裝lnmp1.7(https://www.lnmp.org):
wget http://soft.vpser.net/lnmp/lnmp1.7.tar.gz -cO lnmp1.7.tar.gz && tar zxf lnmp1.7.tar.gz && cd lnmp1.7 && ./install.sh lnmp
選擇需要安裝的軟件版本,參考:
@see: https://www.lnmp.org/install.html
等待半小時左右可知安裝成功:
============================== Check install ==============================
Checking ...
Nginx: OK
Do not install MySQL/MariaDB.
PHP: OK
PHP-FPM: OK
Clean Web Server src directory...
+------------------------------------------------------------------------+
| LNMP V1.7 for Ubuntu Linux Server, Written by Licess |
+------------------------------------------------------------------------+
| For more information please visit https://lnmp.org |
+------------------------------------------------------------------------+
| lnmp status manage: lnmp {start|stop|reload|restart|kill|status} |
+------------------------------------------------------------------------+
| phpMyAdmin: http://IP/phpmyadmin/ |
| phpinfo: http://IP/phpinfo.php |
| Prober: http://IP/p.php |
+------------------------------------------------------------------------+
| Add VirtualHost: lnmp vhost add |
+------------------------------------------------------------------------+
| Default directory: /home/wwwroot/default |
+------------------------------------------------------------------------+
+-------------------------------------------+
| Manager for LNMP, Written by Licess |
+-------------------------------------------+
| https://lnmp.org |
+-------------------------------------------+
nginx (pid 30075) is running...
php-fpm is runing!
State Recv-Q Send-Q Local Address:Port Peer Address:Port
LISTEN 0 128 *:50291 *:*
LISTEN 0 128 *:60437 *:*
LISTEN 0 128 *:22 *:*
LISTEN 0 128 *:49471 *:*
LISTEN 0 64 *:41728 *:*
LISTEN 0 64 *:2049 *:*
LISTEN 0 64 *:39108 *:*
LISTEN 0 128 *:54636 *:*
LISTEN 0 128 *:111 *:*
LISTEN 0 128 *:80 *:*
LISTEN 0 128 *:80 *:*
LISTEN 0 128 *:80 *:*
LISTEN 0 128 *:80 *:*
LISTEN 0 128 :::59795 :::*
LISTEN 0 128 :::22 :::*
LISTEN 0 5 :::4118 :::*
LISTEN 0 64 :::36959 :::*
LISTEN 0 64 :::2049 :::*
LISTEN 0 128 :::34082 :::*
LISTEN 0 128 :::41546 :::*
LISTEN 0 64 :::38252 :::*
LISTEN 0 128 :::51981 :::*
LISTEN 0 128 :::111 :::*
Install lnmp takes 22 minutes.
Install lnmp V1.7 completed! enjoy it.
最后刪除/wwwroot/default下目錄內(nèi)容(出于安全考慮)。
FAQ:
- PHP在運行中發(fā)現(xiàn)一個奇怪的問題,require_once無法加載上級目錄php文件,研究后明白這是fastcgi的一個默認配置,如需支持將/usr/local/nginx/conf/fastcgi.cong下面這段內(nèi)容注釋,否則require無法引入上級目錄的文件
#fastcgi_param PHP_ADMIN_VALUE "open_basedir=$document_root/:/tmp/:/proc/";