1. 程式人生 > >lnmp環境一鍵安裝

lnmp環境一鍵安裝

    lnmp一鍵安裝命令:

wget -c http://soft.vpser.net/lnmp/lnmp1.5.tar.gz && tar zxf lnmp1.5.tar.gz && cd lnmp1.5 && ./install.sh lnmp

如需要安裝LNMPA或LAMP,將./install.sh 後面的引數lnmp替換為lnmpa或lamp即可。如需更改網站和資料庫目錄、自定義Nginx引數、PHP引數模組、開啟lua等需在執行./install.sh 命令前修改安裝包目錄下的 lnmp.conf 檔案,詳細可以檢視

lnmp.conf檔案引數說明

如提示wget: command not found ,使用yum install wget 或 apt-get install wget 命令安裝。

如下載速度慢或無法下載請更換其他下載節點,請檢視LNMP下載節點具體替換方法

執行上述LNMP安裝命令後,會出現如下提示:

目前提供了較多的MySQL、MariaDB版本和不安裝資料庫的選項,需要注意的是MySQL 5.6,5.7及MariaDB 10必須在1G以上記憶體的更高配置上才能選擇!如僅需安裝資料庫在lnmp安裝包目錄下執行:./install.sh db

輸入對應MySQL或MariaDB版本前面的序號,回車進入下一步.


設定MySQL的root密碼(為了安全不輸入直接回車將會設定為lnmp.org#隨機數字)如果輸入有錯誤需要刪除時,可以按住Ctrl再按Backspace鍵進行刪除(個別情況下是隻需要Backspace鍵)。輸入後回車進入下一步,如下圖所示:

詢問是否需要啟用MySQL InnoDB,InnoDB引擎預設為開啟,一般建議開啟,直接回車或輸入 y ,如果確定確實不需要該引擎可以輸入 n,(MySQL 5.7+版本無法關閉InnoDB),輸入完成,回車進入下一步。


注意:選擇PHP 7+版本時需要自行確認PHP版本是否與自己的程式相容。

輸入要選擇的PHP版本的序號,回車進入下一步,選擇是否安裝記憶體優化:

可以選擇不安裝、Jemalloc或TCmalloc,輸入對應序號回車,直接回車為預設為不安裝。

如果是LNMPA或LAMP的話還會提示設定郵箱和選擇Apache“Please enter Administrator Email Address:”,需要設定管理員郵箱,該郵箱會在報錯時顯示在錯誤頁面上。

再選擇Apache版本

按提示輸入對應版本前面的數字序號,回車。

提示"Press any key to install...or Press Ctrl+c to cancel"後,按回車鍵確認開始安裝。 
LNMP指令碼就會自動安裝編譯Nginx、MySQL、PHP、phpMyAdmin等軟體及相關的元件。

安裝時間可能會幾十分鐘到幾個小時不等,主要是機器的配置網速等原因會造成影響。

3、安裝完成
如果顯示Nginx: OK,MySQL: OK,PHP: OK

並且Nginx、MySQL、PHP都是running,80和3306埠都存在,並提示安裝使用的時間及Install lnmp V1.5 completed! enjoy it.的話,說明已經安裝成功。
某些系統可能會一直卡在Install lnmp V1.5 completed! enjoy it.不自動退出,可以按Ctrl+c退出。

 

在安裝linux命令時,忘記mysql密碼,需要修改:

[[email protected] ~]# service mysqld start
[[email protected] ~]#
[[email protected] ~]# mysql -u root 
Type 'help;' or '\h' for help. Type '\c' to clear the current input statement. mysql>

3. 修改密碼

連線mysql這個資料庫,修改使用者密碼

mysql> use mysql;
Reading table information for completion of table and column names
You can turn off this feature to get a quicker startup with -A
 
Database changed
mysql> update mysql.user set authentication_string=password('root_password') where user='root';
Query OK, 1 row affected, 1 warning (0.00 sec) Rows matched: 1 Changed: 1 Warnings: 1 mysql> flush privileges; Query OK, 0 rows affected (0.00 sec) mysql> exit

4. 重啟mysql服務

先將之前加在配置檔案裡面的2句程式碼註釋或刪除掉,然後重啟mysql服務,就可以使用剛剛設定的密碼登入了。

[[email protected] ~]# service mysql start
[[email protected] ~]#
[[email protected] ~]# mysql -u root -p
Enter password: 
Welcome to the MySQL monitor.  Commands end with ; or \g.