亚洲激情专区-91九色丨porny丨老师-久久久久久久女国产乱让韩-国产精品午夜小视频观看

溫馨提示×

溫馨提示×

您好,登錄后才能下訂單哦!

密碼登錄×
登錄注冊×
其他方式登錄
點擊 登錄注冊 即表示同意《億速云用戶服務條款》

NGINX網站服務-LNMP平臺及應用

發布時間:2020-07-31 17:46:02 來源:網絡 閱讀:656 作者:進入倒計時 欄目:數據庫

實驗需求:

LNMP實現多個虛擬主機,部署wordpressphpmyadmin,并為phpmyadmin提供https


實驗環境:

LNMP                 CentOS 7.2x86_64            IP:172.16.251.138

測試端              CentOS 6.7x86_64            IP:172.16.251.164

軟件包:

 initial-setup-ks.cfg
 mariadb-5.5.46-linux-x86_64.tar.gz
 nginx-1.10.0.tar.gz
 php-5.4.26.tar.bz2
 phpMyAdmin-4.4.14.1-all-languages.zip
 wordpress-4.3.1-zh_CN.zip


實驗準備:

安裝開發包組,支持軟件,解決依賴關系

[root@station138 ~]# iptables -F

[root@station138 ~]# setenforce 0

[root@station138 ~]# yum groupinstall"Development Tools" "Server Platform Development"

[root@station138 ~]# yum -y installpcre-devel openssl-devel zlib-devel


編譯安裝nginx:

[root@station138 ~]# tar xfnginx-1.10.0.tar.gz

1.創建程序用戶:

[root@station138 nginx-1.10.0]# useradd -rnginx

2.進入目錄開始編譯:

[root@station138 nginx-1.10.0]# ./configure--prefix=/usr/local/nginx --sbin-path=/usr/sbin/nginx--conf-path=/etc/nginx/nginx.conf --error-log-path=/var/log/nginx/error.log--http-log-path=/var/log/nginx/access.log --pid-path=/var/run/nginx.pid--lock-path=/var/run/nginx.lock --user=nginx --group=nginx --with-http_ssl_module --with-http_v2_module--with-http_dav_module --with-http_stub_status_module --with-threads--with-file-aio

[root@station138 nginx-1.10.0]# make&& make install

3.檢查配置文件:

[root@station138 nginx-1.10.0]# nginx -t

nginx: the configuration file /etc/nginx/nginx.conf syntax is ok

nginx: configuration file /etc/nginx/nginx.conf test is successful


4.啟動服務:

[root@station138 nginx-1.10.0]# nginx

[root@station138 nginx-1.10.0]# netstat-anpt |grep nginx

tcp   0    0 0.0.0.0:80           0.0.0.0:*           LISTEN    38873/nginx: master

5.創建虛擬主機:

[root@station138 ~]# mkdir -pv /var/www/v{1,2}

[root@station138 ~]# echo "web1" >> /var/www/v1/index.html

[root@station138 ~]# echo "web2" >> /var/www/v2/index.html

[root@station138 ~]# vim/etc/nginx/nginx.conf

server {

       listen       80;

       server_name  www.a.com;

       location / {

           root   /var/www/v1;

           index  index.php index.htmlindex.htm;

       }

}

server {

       listen       80;

       server_name  www.b.com;

       location / {

           root   /var/www/v2;

            index  index.php index.html index.htm;

       }

}

[root@station138 ~]# nginx -s reload

6.客戶端測試:

NGINX網站服務-LNMP平臺及應用NGINX網站服務-LNMP平臺及應用


二進制安裝mariadb:

1.建立mysql系統用戶

[root@station138~]# useradd -r -M mysql

2.建立數據存放的目錄

[root@station138~]# mkdir -p /testdir/mydata

[root@station138~]# chown -R mysql.mysql /testdir/mydata

3.解壓mariadb安裝包

[root@station138 ~]#tar xf mariadb-5.5.46-linux-x86_64.tar.gz -C /usr/local

[root@station138~]# ln -sv /usr/local/mariadb-5.5.46-linux-x86_64/ mysql 

[root@station138~]# chown -R root.mysql /usr/local/mysql/*

4.使用scripts腳本文件mysql_install_db文件來安裝數據庫

[root@station138mysql]# scripts/mysql_install_db --user=mysql --datadir=/testdir/mydata

5.提供配置文件

[root@station138mysql]# cp support-files/my-large.cnf /etc/my.cnf

[root@station138mysql]# vim /etc/my.cnf

datadir=/testdir/mydata        //指明mysql的數據存放路徑

innodb_file_per_table = ON   //成為獨立表空間

skip_name_resolve = ON       //跳過名稱解析

6.提供mysql服務啟動腳本

[root@station138 support-files]# cp mysql.server /etc/rc.d/init.d/mysqld  

[root@station138 support-files]# chkconfig --add mysqld

7.添加環境變量

[root@station138 ~]# vim /etc/profile.d/mysql.sh 

export PATH=/usr/local/mysql/bin:$PATH

[root@station138 ~]# source /etc/profile.d/mysql.sh

8.導出頭文件,導出庫文件:

[root@station138 ~]#ln -s /usr/local/include/ /usr/include/mysql

 [root@station138 ~]#vim /etc/ld.so.conf.d/mysql.conf

9.啟動服務

[root@station138 ~]# systemctl start mysqld 

[root@station138 ~]# ss -tnl 

LISTEN     0      50           *:3306     *:*  


源代碼安裝PHP:

1.安裝支持軟件,解決依賴關系:

[root@station138 ~]# yum -y install bzip2-devel libmcrypt-devel libxml2-devel openssl-devel

2.編譯php

[root@station138 ~]# tar xf php-5.4.26.tar.bz2 
[root@station138 ~]# cd php-5.4.26/

[root@station138 php-5.4.26]# ./configure\

 --prefix=/usr/local/php --with-openssl --with-mysql=mysqlnd

 --with-pdo-mysql=mysqlnd --with-mysql=mysqlnd --enable-mbstring 
--with-freetype-dir --with-jpeg-dir --with-png-dir --with-zlib
--with-libxml-dir=/usr --enable-xml --enable-sockets --enable-fpm --with-mcrypt

--with-config-file-path=/etc --with-config-file-scan-dir=/etc/php.d --with-bz2

[root@station138 php-5.4.26]# make && make install

3.php提供配置文件

[root@station138 php-5.4.26]# cp php.ini-production /etc/php.ini

4.提供php-fpm腳本

[root@station138 php-5.4.26]# cp sapi/fpm/init.d.php-fpm /etc/rc.d/init.d/php-fpm
[root@station138 php-5.4.26]# chmod +x /etc/rc.d/init.d/php-fpm 

[root@station138 php-5.4.26]# chkconfig --add php-fpm

5.提供php-fpm配置文件

[root@station138 php-5.4.26]# cd /usr/local/php

[root@station138 php-5.4.26]# cp etc/php-fpm.conf.default etc/php-fpm.conf

6.啟動服務

[root@station138 php-5.4.26]# systemctl start php-fpm
[root@station138 php-5.4.26]# ss -tnl 
State       Recv-Q Send-Q Local Address:Port               Peer Address:Port              

LISTEN      0      128       127.0.0.1:9000                          *:*

7.配置nginx支持php解析:

[root@station138 ~]# vim/etc/nginx/nginx.conf

 server {
        listen       80;
        server_name 
www.a.com;

  location / {
            root   /var/www/v1;
            index  index.php index.html index.htm;
        }
error_page   500 502 503 504  /50x.html;
        location = /50x.html {
            root   html;
        }

location ~ \.php$ {
            root           /var/www/v1;
            fastcgi_pass   127.0.0.1:9000;
            fastcgi_index  index.php;
            fastcgi_param  SCRIPT_FILENAME  /var/www/v1/$fastcgi_script_name;
            include        fastcgi_params;
        }

}

 server {
              listen       80;
             server_name  www.b.com;
             location / {
                        root   /var/www/v2;
                        index  index.php index.html index.htm;
             }
        location ~ \.php$ {
            root           /var/www/v2;
            fastcgi_pass   127.0.0.1:9000;
            fastcgi_index  index.php;
            fastcgi_param  SCRIPT_FILENAME  /var/www/v2/$fastcgi_script_name;
   
         include        fastcgi_params;
        }

[root@station138 ~]# nginx -s reload

8.客戶端測試php:

NGINX網站服務-LNMP平臺及應用

9.創建數據庫,授權用戶

[root@station138 nginx]# mysql -uroot –p


MariaDB [(none)]> create database wpdb;


Query OK, 1 row affected (0.00 sec)


MariaDB [(none)]> grant all on wpdb.* to 'wpuser'@'172.16.%.%' identified by 'wp123';


Query OK, 0 rows affected (0.14 sec)


MariaDB [(none)]> create database pma;


Query OK, 1 row affected (0.00 sec)


MariaDB [(none)]> grant all on pma.* to 'pmauser'@'172.16.%.%' identified by 'pma123';


Query OK, 0 rows affected (0.00 sec)


10.測試mysql-php:

[root@station138 ssl]# cat /var/www/v1/index.php
web1
<?php
 $link = mysql_connect('localhost','root','123456');
 if($link)
  echo "OK";
 else
  echo "no";
?>

NGINX網站服務-LNMP平臺及應用


部署應用:

1.部署wordpress:

[root@station138 ~]# unzip wordpress-4.3.1-zh_CN.zip


[root@station138 ~]# mv wordpress /var/www/v1/


[root@station138 wordpress]# mv wp-config-sample.php wp-config.php

[root@station138 wordpress]# vim wp-config.php 
/** WordPress數據庫的名稱 */
define('DB_NAME', 'wpdb');
/** MySQL數據庫用戶名 */
define('DB_USER', 'wpuser');
/** MySQL數據庫密碼 */
define('DB_PASSWORD', 'wp123');
/** MySQL主機 */

define('DB_HOST', '172.16.251.138');

2.部署phpMyAdmin:

[root@station138 ~]# unzip phpMyAdmin-4.4.14.1-all-languages.zip
[root@station138 ~]# mv phpMyAdmin-4.4.14.1-all-languages /var/www/v2
[root@station138 v2]# ln -sv phpMyAdmin-4.4.14.1-all-languages/ pma
[root@station138 v2]# vim phpmyadmin/libraries/config.default.php
$cfg['blowfish_secret'] = 'tSQRO02T+grA6rvJHCXr';
$cfg['Servers'][$i]['host'] = '172.16.251.138'; 
$cfg['Servers'][$i]['user'] = 'pmauser';

$cfg['Servers'][$i]['password'] = 'pma123';

3.客戶端測試應用:

NGINX網站服務-LNMP平臺及應用NGINX網站服務-LNMP平臺及應用NGINX網站服務-LNMP平臺及應用


為phpmyadmin提供https:

1.生成私鑰:

[root@station138 CA]# (umask 077; opensslgenrsa -out private/cakey.pem 2048)

2.生成自簽證書:

[root@station138 CA]# openssl req -new-x509 -key private/cakey.pem -out cacert.pem 

Country Name (2 letter code) [XX]:CN

State or Province Name (full name) []:bj

Locality Name (eg, city) [Default City]:bj

Organization Name (eg, company) [DefaultCompany Ltd]:yw

Organizational Unit Name (eg, section)[]:Ops

Common Name (eg, your name or your server'shostname) []:www.b.com

Email Address []:admin@b.com

3.提供輔助文件

[root@station138 CA]#touch index.txt

[root@station138 CA]#echo 01 > serial

4.生成私鑰:

[root@station138 ssl]#  (umask 077; openssl genrsa -out nginx.key1024)

5.生成證書請求:

[root@station138 ssl]#  openssl req -new -key nginx.key -outnginx.csr

Country Name (2 letter code) [XX]:CN

State or Province Name (full name) []:bj

Locality Name (eg, city) [Default City]:bj

Organization Name (eg, company) [DefaultCompany Ltd]:yw

Organizational Unit Name (eg, section)[]:Ops

Common Name (eg, your name or your server'shostname) []:www.b.com

Email Address []:admin@b.com

Please enter the following 'extra'attributes

to be sent with your certificate request

A challenge password []:

An optional company name []:

6.簽發證書:

[root@station138 ssl]#  openssl ca -in /testdir/nginx.csr -out/etc/pki/CA/certs/nginx.crt

[root@station138 ssl]# cp/etc/pki/CA/certs/nginx.crt /etc/nginx/ssl/

7.修改nginx配置文件,添加支持ssl:

[root@station138 ~]# vim /etc/nginx/nginx.conf

server {
        listen       443 ssl;
        server_name  localhost;

        ssl_certificate      /etc/nginx/ssl/nginx.crt;
        ssl_certificate_key  /etc/nginx/ssl/nginx.key;

        ssl_session_cache    shared:SSL:1m;
        ssl_session_timeout  5m;

        ssl_ciphers  HIGH:!aNULL:!MD5;
        ssl_prefer_server_ciphers  on;

        location / {
            root   html;
            index index.php index.html index.htm;
        }
    }

8.測試https:

NGINX網站服務-LNMP平臺及應用NGINX網站服務-LNMP平臺及應用NGINX網站服務-LNMP平臺及應用

向AI問一下細節

免責聲明:本站發布的內容(圖片、視頻和文字)以原創、轉載和分享為主,文章觀點不代表本網站立場,如果涉及侵權請聯系站長郵箱:is@yisu.com進行舉報,并提供相關證據,一經查實,將立刻刪除涉嫌侵權內容。

AI

谢通门县| 太仓市| 枣阳市| 开封县| 呼和浩特市| 启东市| 会泽县| 光泽县| 绥阳县| 磴口县| 英德市| 襄垣县| 铁力市| 龙山县| 南郑县| 抚远县| 蛟河市| 安徽省| 惠州市| 张家港市| 陆河县| 临武县| 渝中区| 扎鲁特旗| 仪征市| 高碑店市| 怀安县| 大埔区| 安岳县| 绩溪县| 甘德县| 东安县| 肥乡县| 陆川县| 万荣县| 东莞市| 观塘区| 广州市| 华宁县| 清水河县| 揭阳市|