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
#官方網(wǎng)站安裝
# 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數(shù)據(jù)庫
安裝Mariadb數(shù)據(jù)庫
[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產(chǎn)品,解壓并部署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產(chǎn)品需要依賴數(shù)據(jù)庫,所以需要手動建立數(shù)據(jù)庫
[root@nginx ~]# mysql -uroot -plzy123.com
mysql> create database wordpress;
mysql> exit`