lnmp一鍵安裝包搭建lnmp環境

linux裏的基礎二個:lamp和lnmp。php

1、下載lnmp安裝包:
      wget http://202.115.33.13/soft/lnmp/lnmp1.5.tar.gz
      若是沒有wget工具yum安裝一個: yum  -y install wgethtml

 

2、解壓並啓用lnmp:tar -zxvf lnmp1.5.tar.gz  && cd lnmp1.5 && ./install.sh
     一、選擇mysql版本:mysql

    二、建立mysql的root:linux

    三、是否啓用或禁用InnoDB存儲引擎嗎?nginx

   四、選擇php版本:sql

   五、內存分配器安裝有3個選項選擇默認就能夠直接回車:數據庫

   六、開始安裝(就慢慢等吧睡會也行...):vim

七、這裏記得回車一下!!!安裝時間可能會幾十分鐘到幾個小時不等,主要是機器的配置網速等緣由會形成影響php-fpm

3、安裝後查看端口是否服務都安裝成功: netstat -utpln  工具

##Nginx、MySQL、PHP都是running,80和3306端口都存在,說明已經安裝成功。

 

4、安裝好lnmp環境,配置mysql數據庫

一、免密登陸:vim /etc/my.cnf   [mysqld] 下面加上skip-grant-tables 保存退出

二、重啓mysql服務:service mysql restart

三、執行 mysql -uroot -p ,不輸入密碼直接回去進入mysql

四、修改root密碼:

輸入show databases;   能夠看到全部數據庫說明成功登錄

輸入 use mysql;   選擇mysql數據庫。

 輸入select user,host,password from user;   來查看帳戶信息。

更改root密碼,輸入update user set password=password('123456') where user='root' and host='localhost'; 密碼最好包含特殊符號、大小寫字母 、不一樣版本的mysql可能沒有password 而是authentication_string

再次查看帳戶信息,select user,host,password from user;   能夠看到密碼已被修改。

退出: exit;

五、修改完root密碼,再把vim /etc/my.cnf 下的 skip-grant-tables 註釋掉 #skip-grant-tables;

六、重啓mysql服務:service mysql restart

七、從新進入mysql :mysql -uroot -p,輸入設置的新密碼,回車!

八、修改訪問IP限制建立遠程鏈接帳號:GRANT ALL PRIVILEGES ON *.* TO 'root'@'%' IDENTIFIED BY '123456' WITH GRANT OPTION;

九、flush privileges; 從新加載權限

 

 5、啓動php-fpm 

從新啓動php-fpm過程當中遇到一個報錯。

 An another FPM instance seems to already listen on /tmp/php-cgi.sock
# netstat -ant | grep 9000  //查看啓動進程,發現沒啓動成功

咱們去查看一下php-fpm.conf裏面的配置:

# vim  /usr/local/php/etc/php-fpm.conf  
複製代碼
[www]
listen = /tmp/php-cgi.sock   //注意這行應該刪除
listen = 127.0.0.1:9000 //新增監聽9000端口
listen.backlog = -1 listen.allowed_clients = 127.0.0.1 listen.owner = www listen.group = www
複製代碼

此時咱們須要根據配置文件的listen地址作對應的修改:

# vim /usr/local/nginx/conf/nginx.conf
複製代碼
location ~ [^/]\.php(/|$) {
       fastcgi_pass unix:/tmp/php-cgi.sock;    //把127.0.0.1:9000改成此行
       fastcgi_index index.php;
       fastcgi_param SCRIPT_FILENAME     $document_root$fastcgi_script_name;
       include fastcgi_params;
}
location / {
      root   html;
      index index.php index.html index.htm;
}
複製代碼

修改完平滑重啓nginx,而後啓動php-fpm,OK

相關文章
相關標籤/搜索