LNMP部署及HTTPS服务开启教程

2019-01-16 20:51:30王振洲

LNMP是什么 : Linux+Nginx+Mysql+(php-fpm,php-mysql)

                         即在Linux操作系统上Nginx+Mysql+Php的网站服务架构。

                         CentOS 6中为MySQL,CentOS 7中为Mariadb

  作用是什么    : 提供web服务,并可以解析PHP类的应用程序;

  下面我就利用LNMP架构部署phpMyAdmin:

   前提:这次操作均在172.16.75.1主机上进行;

    1.  为web服务器配置一个域名:www.sss.com

      在物理机的C盘下的windows/System32/drivers/etc/etc/hosts文件中添加一条记录:

      172.16.75.1 www.sss.com     

    2. 在172.16.75.1主机上部署LNMP架构:

[root@master ~]# yum install nginx mariadb php-fpm php-mysql

    在这估计大家会提出疑问,php-fpm,php-mysql的作用是什么呢?

    因为Nginx只是提供web服务,不能解析PHP应用,而php-fpm可以

    而php-mysql用来连接PHP应用和Mariadb的;

    3. 配置:

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

  

[root@master ]# nginx -t nginx: the configuration file /etc/nginx/nginx.conf syntax is ok nginx: configuration file /etc/nginx/nginx.conf test is successfu

  测试Nginx配置无错,开启服务:

[root@master ~]# systemctl start nginx

 开启php-fpm服务:

[root@master ~]# systemctl start php-fpm

 创建一个目录用于存放资源,在nginx.conf中已经定义:

[root@master ~]# mkdir -pv /myweb/nginx/

 我事先已将wordpress和phpMyAdmin的包放到该目录下:

 首先部署phpMyAdmin(用来管理数据库)应用

 解压:

[root@master ~]# cd /myweb/nginx/ [root@master nginx]# tar -xf phpMyAdmin-3.5.4-all-languages.tar.gz [root@master nginx]# mv phpMyAdmin-3.5.4-all-languages pma

在/var/lib/php下创建目录session:

  属主为root,属组为apache,权限为770;

[root@master ~]# cd /var/lib/php [root@master php]# mkdir session [root@master php]# chown root:apache session/ [root@master php]# chmod 770 session/

给管理员配置一个数据库的管理密码:

[root@master ~]# mysqladmin -p'' password '111111' Enter password: