LNMP是一套技术组合,L=Linux,N=nginx,M=Mysql,P=PHP
[外链图片转存失败,源站可能有防盗链机制,建议将图片保存下来直接上传(img-2iBznQlR-1616923640288)(5C478F3393E44896A296A364456EC900)]
解析上图:
[root@web01 ~]# yum install -y gcc gcc-c++ autoconf pcre pcre-devel make
[root@web01 ~]#vim /etc/yum.repos.d/nginx.reop
[nginx]
name=nginx repo
baseurl=http://nginx.org/packages/centos/7/$basearch/
gpgcheck=0
enabled=1
[root@web01 ~]#yum -y install nginx
[root@web01 ~]#groupadd -g666 www
[root@web01 ~]#useradd -u666 -g666 -M -s /sbin/nologin www
[root@web01 ~]#sed -i '/^user/c user www;' /etc/nginx/nginx.conf #修改nginx配置文件
[root@web01 ~]#systemctl start nginx
[root@web01 ~]#systemctl enable nginx
[root@web01 ~]# ps axu|grep nginx
[root@web01 ~]# rpm -Uvh https://dl.fedoraproject.org/pub/epel/epel-release-latest-7.noarch.rpm
[root@web01 ~]# rpm -Uvh https://mirror.webtatic.com/yum/el7/webtatic-release.rpm
[root@web01 ~]# yum remove php-mysql-5.4 php php-fpm php-common
[root@web01 ~]#vim /etc/yum.repos.d/php.repo
[root@web01 ~]#yum -y install php71w php71w-cli php71w-common php71w-devel php71w-embedded php71w-gd php71w-mcrypt php71w-mbstring php71w-pdo php71w-xml php71w-fpm php71w-mysqlnd php71w-opcache php71w-pecl-memcached php71w-pecl-redis php71w-pecl-mongodb --nogpgcheck
[root@web01 ~]#sed -i '/^user/c user = www' /etc/php-fpm.d/www.conf
[root@web01 ~]#sed -i '/^group/c group = www' /etc/php-fpm.d/www.conf
[root@web01 ~]#systemctl start php-fpm
[root@web01 ~]#systemctl enable php-fpm
[root@web01 ~]# netstat -lntup
tcp 0 0 127.0.0.1:9000 0.0.0.0:* LISTEN 1879/php-fpm: maste
[root@web01 ~]# ps aux|grep php-fpm
root 1879 0.0 3.2 490176 32640 ? Ss 22:22 0:00 php-fp: master process (/etc/php-fpm.conf)
www 1880 0.0 0.7 490176 7592 ? S 22:22 0:00 php-fp
[root@web01 ~]# yum -y install mariadb-server
[root@web01 ~]# systemctl start mariadb
[root@web01 ~]# systemctl enable mariadb
[root@web01 ~]# mysqladmin password 'aaa123.com'
[root@web01 ~]# mysql -uroot -paaa123.com
MariaDB [(none)]> #出现则正确
[root@web01 ~]# mkdir /code
[root@web01 ~]# cd /code/
[root@web01 code]# wget https://cn.wordpress.org/wordpress-5.0.3-zh_CN.tar.gz
[root@web01 code]# tar xf wordpress-5.0.3-zh_CN.tar.gz
[root@web01 code]# rm -rf wordpress-5.0.3-zh_CN.tar.gz
[root@web01 code]# chown -R www.www /code/wordpress
[root@web01 code]# mysql -uroot -paaa123.com -e "create database wordpress;"
[root@web01 code]# mysql -uroot -paaa123.com -e "show databases;"
[root@web01 ~]# cd /etc/nginx/conf.d/
[root@web01 conf.d]# vim wordpress.conf
server {
listen 80;
server_name wordpress.sheng.com;
root /code/wordpress;
index index.php index.html;
location ~ \.php$ {
root /code/wordpress;
fastcgi_pass 127.0.0.1:9000;
fastcgi_index index.php;
fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
include fastcgi_params;
}
}
[root@web01 conf.d]# nginx -t
nginx: the configuration file /etc/nginx/nginx.conf syntax is ok
nginx: configuration file /etc/nginx/nginx.conf test is successful
[root@web01 conf.d]# systemctl reload nginx
[root@web01 conf.d]# vim zh.conf
server {
listen 80;
server_name zh.sheng.com;
root /code/zh;
index index.php index.html;
location ~ \.php$ {
root /code/zh;
fastcgi_pass 127.0.0.1:9000;
fastcgi_index index.php;
fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
include fastcgi_params;
}
}
[root@web01 ~]# cd /code
[root@web01 code]# mkdir zh
https://www.wecenter.com/downloads/
[root@web01 zh]# unzip WeCenter_3-6-0.zip
[root@web01 zh]# chown -R www.www /code/zh/
[root@web01 zh]# mysql -uroot -paaa123.com -e "create database zh;"
[root@web01 zh]# mysql -uroot -paaa123.com -e "show databases;"
[root@web01 conf.d]# nginx -t
nginx: the configuration file /etc/nginx/nginx.conf syntax is ok
nginx: configuration file /etc/nginx/nginx.conf test is successful
[root@web01 zh]# systemctl reload nginx
[root@web01 conf.d]# vim phpshe.conf
server {
listen 80;
server_name phpshe.sheng.com;
root /code/phpshe;
index index.php index.html;
location ~ \.php$ {
root /code/phpshe;
fastcgi_pass 127.0.0.1:9000;
fastcgi_index index.php;
fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
include fastcgi_params;
}
}
[root@web01 conf.d]# nginx -t
nginx: the configuration file /etc/nginx/nginx.conf syntax is ok
nginx: configuration file /etc/nginx/nginx.conf test is successful
[root@web01 code]# mkdir phpshe
[root@web01 phpshe]# chown -R www.www /code/phpshe/
[root@web01 ~]# mysql -uroot -paaa123.com -e "create database phpshe;"
[root@web01 ~]# mysql -uroot -paaa123.com -e "show databases;"