CentOS上利用nginx+php+mysql搭建wordpress环境
1、安装nginx
yum install nginx
nginx的网站目录位于:
/usr/share/nginx/html
nginx的配置文件位于:
/etc/nginx/nginx.conf
nginx -t 测试配置文件
nginx -v 查看相关版本
2、安装mysql
yum install mysql-server
service mysqld start
设置密码
/usr/bin/mysql_secure_installation
修改root密码后,登陆,新建一个wordpress数据库及用户
mysql> create database wordpress;
mysql> grant all privileges on iqilife.* to iqilifer@'%' identified by 'TgHV8h9YOj86FEh';
mysql> flush privileges;
3、安装php
yum search php-
或者编译安装
cd /usr/local/src
wget https://cn2.php.net/distributions/php-5.6.22.tar.gz
./configure --prefix=/usr/local/php --enable-fpm --with-mcrypt --enable-mbstring --disable-pdo --with-curl --disable-debug --disable-rpath --enable-inline-optimization --with-bz2 --with-zlib --enable-sockets --enable-sysvsem --enable-sysvshm --enable-pcntl --enable-mbregex --with-mhash --enable-zip --with-pcre-regex --with-mysql --with-mysqli --with-gd --with-jpeg-dir
make all install
cd /usr/local/php
cp etc/php-fpm.conf.default etc/php-fpm.conf
启动php-fpm
cd /usr/local/php/sbin
./php-fpm
编写一个测试页面,查看 php环境配置是否正常
vim /usr/share/nginx/html/info.php
<?php
phpinfo();
?>
然后在浏览器中输入 https://IP/info.php
4、配置nginx
修改nginx配置文件为
user nobody;
worker_processes 4;
#error_log logs/error.log;
#error_log logs/error.log notice;
#error_log logs/error.log info;
#pid logs/nginx.pid;
events {
worker_connections 10240;
}
http {
include mime.types;
default_type application/octet-stream;
#log_format main '$remote_addr - $remote_user [$time_local] "$request" '
# '$status $body_bytes_sent "$http_referer" '
# '"$http_user_agent" "$http_x_forwarded_for"';
access_log logs/access.log ;
sendfile on;
#tcp_nopush on;
#keepalive_timeout 0;
keepalive_timeout 65;
#limit_conn_zone $binary_remote_addr zone=perip:10m;
server {
listen 80;
server_name 192.168.85.44;
#limit_conn perip 5;
#charset koi8-r;
access_log logs/access.log ;
location / {
root /usr/share/nginx/html;
index index.php index.html index.htm;
try_files $uri $uri/ /index.php?q=$uri&$args;
if (-f $request_filename) {
expires 30d;
break;
}
if (!-e $request_filename) {
rewrite ^(.+)$ /index.php?q=$1 last;
}
}
# pass the PHP scripts to FastCGI server listening on 127.0.0.1:9000
location ~ .php$ {
try_files $uri =404;
include /etc/nginx/fastcgi_params;
fastcgi_pass 127.0.0.1:9000;
fastcgi_index index.php;
fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
}
}
}
5、、安装wordpress
cd /usr/share/nginx/html
wget https://cn.wordpress.org/wordpress-4.5.2-zh_CN.tar.gz
tar zxvf wordpress-4.5.2-zh_CN.tar.gz
mv wordpress/* .
然后在浏览器输入 https://ip/wp-admin/indstall 然后按照提示,输入数据库信息,进行安装
至此,在centos下配置wordpress环境,配置完成。
评论