一、CentOS-6.8-x86_64-minimal.iso安装系统后重启进入系统,默认是没有网络的,需手动设置网络:
[[email protected] ~]#vi /etc/sysconfig/network-scripts/ifcfg-eth0
DEVICE=eth0
HWADDR=26:96:6A:AC:A7:85
TYPE=Ethernet
ONBOOT=yes
NM_CONTROLLED=no
BOOTPROTO=static
IPADDR=192.168.35.100
NETMASK=255.255.255.0
GATEWAY=192.168.35.1
DNS1=8.8.8.8
DNS2=8.8.4.4
:wq!
[[email protected] ~]#service network restart
暂时不需开启postfix,所以关闭了它:
[[email protected] ~]#service postfix stop
[[email protected] ~]#chkconfig postfix off
二、安装系统常用工具软件
[[email protected] ~]#yum install setuptool
[[email protected] ~]#yum install ntsysv
#yum install iptables#已安装
[[email protected] ~]#yum install system-config-securitylevel-tui
[[email protected] ~]#yum install system-config-network-tui
[[email protected] ~]#yum install wget
[[email protected] ~]#yum install gcc
#yum install make#已安装
[[email protected] ~]#yum install unzip
三、安装LEMP必需的存储库
[[email protected] ~]#yum install epel-release
四、安装nginx、mysql、php
On RHEL/CentOS 7
[[email protected] ~]#yum install nginx mariadb mariadb-server php php-fpm php-common php-mysql php-gd php-xml php-mbstring php-mcrypt
On RHEL/CentOS 6/5
[[email protected] ~]#yum install nginx mysql mysql-server php php-fpm php-common php-mysql php-gd php-xml php-mbstring php-mcrypt
五、启动mysql和nginx服务
[[email protected] ~]#/etc/init.d/mysqld start
通过以下命令配置mysql和设置密码:
[[email protected] ~]#/usr/bin/mysql_secure_installation
因为还没设置mysql密码,当前mysql密码是空的,所以提示以下信息直接回车然后设置个新密码:
Enter current password for root (enter for none):
OK, successfully used password, moving on...
Remove anonymous users? [Y/n] y
Disallow root login remotely? [Y/n] y
Remove test database and access to it? [Y/n] y
Reload privilege tables now? [Y/n] y
启动nginx服务
[[email protected] ~]#/etc/init.d/nginx start
六、设置php:
[[email protected] ~]#vi /etc/php.ini
#Find the line, cgi.fix_pathinfo=1, and change the 1 to 0.
cgi.fix_pathinfo=0
#date.timezone = PRC
expose_php = Off
short_open_tag = On
:wq!
[[email protected] ~]#vi /etc/php-fpm.d/www.conf
user = nginx
group = nginx
:wq!
七、配置nginx:
[[email protected] ~]#vi /etc/nginx/nginx.conf
user nginx;
:wq!
[[email protected] ~]#vi /etc/nginx/conf.d/default.conf
server {
listen 80;
server_name localhost;
location / {
root /usr/share/nginx/html;
index index.php index.html index.htm;
}
error_page 404 /404.html;
location = /404.html {
root /usr/share/nginx/html;
}
error_page 500 502 503 504 /50x.html;
location = /50x.html {
root /usr/share/nginx/html;
}
# pass the PHP scripts to FastCGI server listening on 127.0.0.1:9000
#
location ~ \.php$ {
root /usr/share/nginx/html;
fastcgi_pass 127.0.0.1:9000;
fastcgi_index index.php;
fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
include fastcgi_params;
}
}
:wq!
八、重启nginx和php-fpm服务,以使上面的设置生效:
[[email protected] ~]#service nginx restart
[[email protected] ~]#service php-fpm restart
清空防火墙规则:
[[email protected] ~]#iptables -F
[[email protected] ~]#service iptables save
#iptables: Saving firewall rules to /etc/sysconfig/iptables:[ OK ]
九、现在可以打开浏览器,输入http://youripadress/
正常情况你会看到一个网页表示设置成功了。
十、 设置开机自启动mysql、nginx、php-fpm三项服务。
[[email protected] ~]#chkconfig --levels 235 mysqld on
[[email protected] ~]#chkconfig --levels 235 nginx on
[[email protected] ~]#chkconfig --levels 235 php-fpm on
十一、下载、解压WordPress中文版
[[email protected] ~]#cd /opt
[[email protected] ~]#wget https://cn.wordpress.org/wordpress-4.7.4-zh_CN.tar.gz
[[email protected] ~]#tar -xvzf wordpress-4.7.4-zh_CN.tar.gz -C /usr/share/nginx/html/
设置相应的权限
[[email protected] ~]#chown -R nginx:nginx /usr/share/nginx/html/wordpress
[[email protected] ~]#chmod -R 755 /usr/share/nginx/html/wordpress
十二、建立wordpress数据库、账号和设置密码权限:
[[email protected] ~]#mysql -u root -p
mysql> CREATE DATABASE demo DEFAULT CHARSET utf8 COLLATE utf8_general_ci;
mysql> CREATE USER demo@localhost;
mysql> SET PASSWORD FOR demo@localhost= PASSWORD("yoursqlpassword");
mysql> GRANT ALL PRIVILEGES ON demo.* TO demo@localhost IDENTIFIED BY 'yoursqlpassword';
mysql> FLUSH PRIVILEGES;
mysql> exit
十三、配置Nginx虚拟主机demo.itkylin.com
[[email protected] ~]#vi /etc/nginx/conf.d/demo.itkylin.com.conf
server {
listen 80;
server_name demo.itkylin.com;
root /usr/share/nginx/html/wordpress;
index index.php index.html;
location / {
try_files $uri $uri/ @handler;
}
location @handler {
fastcgi_pass 127.0.0.1:9000;
fastcgi_param SCRIPT_FILENAME /usr/share/nginx/html/wordpress/index.php;
include /etc/nginx/fastcgi_params;
fastcgi_param SCRIPT_NAME /index.php;
}
location ~ .php$ {
try_files $uri @handler;
fastcgi_pass 127.0.0.1:9000;
fastcgi_index index.php;
fastcgi_param SCRIPT_FILENAME /usr/share/nginx/html/wordpress$fastcgi_script_name;
include fastcgi_params;
}
}
:wq!
重启nginx服务让设置生效:
On RHEL/CentOS 7
[[email protected] ~]#systemctl restart nginx
On RHEL/CentOS 6/5
[[email protected] ~]#service nginx restart
十四、设置wordpress的安装配置信息:
[[email protected] ~]#chown -R nginx:nginx /usr/share/nginx/html/wordpress
[[email protected] ~]#cd /usr/share/nginx/html/wordpress
[[email protected] ~]#cp wp-config-sample.php wp-config.php
[[email protected] ~]#chmod 777 wp-config.php
[[email protected] ~]#chown nginx:nginx wp-config.php
[[email protected] ~]#vi wp-config.php
define('DB_NAME', 'demo');
define('DB_USER', 'demo');
define('DB_PASSWORD', 'yoursqlpassword');
:wq!
十五、打开浏览器输入域名开始安装wordpress
http://demo.itkylin.com
十六、Enjoy it!