1配置防火墙
Iptables -A INPUT -m state --state NEW -m tcp -p tcp --dport 80 -j ACCEPT #允许80端口通过防火墙 iptables-A INPUT -m state --state NEW -m tcp -p tcp --dport 3306 -j ACCEPT #允许3306端口通过防火墙 service iptables save
2关闭SELINUX
Setgenfoce 0
vi /etc/selinux/config
#SELINUX=enforcing #SELINUXTYPE=targeted SELINUX=disabled
3卸载httpd php
yum remove httpd* php*
4安装并启动nginx
yum install nginx -y #安装nginx chkconfig nginx on #设置nginx开机启动 service nginx start #启动nginx
5安装并启动mysql
yum install mysql mysql-server service mysqld start chkcongfig mysqld on cp /usr/share/mysql/my-medium.cnf /etc/my.cnf
6为mysql设置密码
mysqladmin -uroot password mypassword
7为wordpress创建库
mysql -uroot -p mypassword mysql>create database wordpress; mysql>desc database; mysql>Bye
8安装PHP
yum install -y php-mysql php-gd libjpeg* php-imap php-ldap php-odbc php-pear php-xml php-xmlrpc php-mbstring php-mcrypt php-bcmath php-mhash libmcrypt php php-fpm
9配置nginx
cp /etc/nginx/nginx.conf /etc/nginx/nginx.confbak
vi /etc/nginx/nginx.conf
user nginx;
nginx.conf优化和上传的限制 worker_processes 8; events { use epoll; worker_connections 65535; } http { include mime.types; default_type application/octet-stream; client_max_body_size 100m; client_header_buffer_size 128k; large_client_header_buffers 4 128k; sendfileon; tcp_nopush on; tcp_nodelay on; keepalive_timeout 65; include /etc/nginx/vhost/*; gzip on; gzip_min_length 1k; gzip_buffers 4 16k; gzip_http_version 1.1; gzip_comp_level 2; gzip_types text/plain application/x-javascript text/css application/xml; gzip_vary on;
cp /etc/nginx/conf.d/default.conf /etc/nginx/conf.d/default.confbak
vi /etc/nginx/conf.d/default.conf
index index.php index.html index.htm; location ~ \.php$ { root html; fastcgi_pass 127.0.0.1:9000; fastcgi_index index.php; fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name; include fastcgi_params; } 解决固定连接404问题 location / { root /usr/local/www/nginx; index index.php index.html index.htm; if (-f $request_filename/index.html){ rewrite (.*) $1/index.html break; } if (-f $request_filename/index.php){ rewrite (.*) $1/index.php; } if (!-f $request_filename){ rewrite (.*) /index.php; } } service nginx restart
10配置PHP
vi /etc/php.ini
date.timezone = PRC expose_php = Off short_open_tag = ON open_basedir = .: post_max_size = 20m upload_max_filesize = 20M max_file_uploads = 200
11配置php-fpm
cp /etc/php-fpm.d/www.conf /etc/php-fpm.d/www.confbak
vi /etc/php-fpm.d/www.conf
user = nginx
group = nginx
cd /usr/share/nginx/html
vi index.php
<?php phpinfo(); ?>
访问你的网站/info.php测试
12安装wordpress
unzip wordpress-4.5.2-zh_CN.zip cd wordpress cp -r ./* /usr/share/nginx/html/ cd /usr/share/nginx/html cp wp-config-smaple.php wp-congfig.php vi wp-config.php define('DB_NAME', 'wordpress'); /** MySQL数据库用户名 */ define('DB_USER', 'root'); /** MySQL数据库密码 */ define('DB_PASSWORD', 'mypassword'); /** MySQL主机 */ define('DB_HOST', 'localhost'); /** 创建数据表时默认的文字编码 */ define('DB_CHARSET', 'utf8'); /** 数据库整理类型。如不确定请勿更改 */ define('DB_COLLATE', '');
13切换用户和权限
不做这步的话安装插件需要FTP服务 cd ../ chown -R html/* chmod 755 html/* -R 或者也可以编辑wp-config.php /** Override default file permissions */ if(is_admin()) { add_filter('filesystem_method', create_function('$a', 'return "direct";' )); define( 'FS_CHMOD_DIR', 0751 ); }
14访问你的网站/wp-admin按提示安装
原创文章,作者:双庆 李,如若转载,请注明出处:http://www.178linux.com/18034