Nginx location
#LNMP搭建
Linux+Nginx+MySQL+PHP
Nginx
安装nginx
cat /etc/yum.repos.d/nginx.repo
[nginx-stable]
name=nginx stable repo
baseurl=http://nginx.org/packages/centos/$releasever/$basearch/
gpgcheck=0
enabled=1
gpgkey=https://nginx.org/keys/nginx_signing.key
module_hotfixes=true
#############################
yum install nginx -y
修改Nginx用户
[root@nginx ~]# groupadd www -g 666
[root@nginx ~]# useradd www -u 666 -g 666 -s /sbin/nologin -M
#修改nginx配置文件
[root@nginx ~]# sed -i '/^user/c user www;' /etc/nginx/nginx.conf
启动Nginx加入开机自启
[root@nginx ~]# systemctl start nginx
[root@nginx ~]# systemctl enable nginx
PHP
安装php
#官方网站安装
# rpm -Uvh https://dl.fedoraproject.org/pub/epel/epel-release-latest-7.noarch.rpm
# rpm -Uvh https://mirror.webtatic.com/yum/el7/webtatic-release.rpm
[root@nginx ~]# yum remove php-mysql-5.4 php php-fpm php-common
#配置第三方源安装
[root@nginx ~]# vim /etc/yum.repos.d/php.repo
[php-webtatic]
name = PHP Repository
baseurl = http://us-east.repo.webtatic.com/yum/el7/x86_64/
gpgcheck = 0
#安装依赖
[root@nginx ~]# 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
配置php-fpm用户与Nginx的运行用户保持一致
[root@nginx ~]# sed -i '/^user/c user = www' /etc/php-fpm.d/www.conf
[root@nginx ~]# sed -i '/^group/c group = www' /etc/php-fpm.d/www.conf
启动php-fpm加入开机自启
[root@nginx ~]# systemctl start php-fpm
[root@nginx ~]# systemctl enable php-fpm
Mariadb数据库
安装Mariadb数据库
[root@nginx ~]# yum install mariadb-server -y
启动Mariadb加入开机自动
[root@nginx ~]# systemctl start mariadb
[root@nginx ~]# systemctl enable mariadb
给Mariadb配置登陆密码
[root@nginx ~]# mysqladmin password 'lzy123.com'
[root@nginx ~]# mysql -uroot -plzy123.com
#wordpress搭建
1.nginx具体配置信息
[root@web01 conf.d]# vim wordpress.conf
server {
listen 80;
server_name wordpress.oldboy.com;
location / {
root /code/wordpress;
index index.php index.html;
}
location ~ \.php$ {
root /code/wordpress;
fastcgi_pass 127.0.0.1:9000;
fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
include fastcgi_params;
}
}
2)重启nginx服务
[root@nginx ~]# systemctl restart nginx
3)获取wordpress产品,解压并部署wordress
[root@nginx ~]# mkdir /code
[root@nginx ~]# cd /code
[root@nginx code]# wget https://cn.wordpress.org/wordpress-5.0.3-zh_CN.tar.gz
永远下载最新版
[root@nginx code]# wget https://cn.wordpress.org/latest-zh_CN.tar.gz
[root@nginx ~]# tar xf wordpress-5.0.3-zh_CN.tar.gz
[root@nginx ~]# chown -R www.www /code/wordpress/
4)由于wordpress产品需要依赖数据库,所以需要手动建立数据库
[root@nginx ~]# mysql -uroot -plzy123.com
mysql> create database wordpress;
mysql> exit`