Wordpress 安裝部署php
1 前言html
WordPress是一個注重美學、易用性和網絡標準的我的信息發佈平臺。WordPress雖爲免費的開源軟件,但其價值沒法用金錢來衡量。mysql
WordPress的圖形設計在性能上易於操做、易於瀏覽;在外觀上優雅大方、風格清新、色彩誘人。linux
使用WordPress能夠搭建功能強大的網絡信息發佈平臺,但更多的是應用於個性化的博客。針對博客的應用,WordPress能讓您省卻對後臺技術的擔憂,集中精力作好網站的內容。nginx
如下是wordpress安裝部署方法。web
nginx(yum) + php(編譯) + mysql(二進制)sql
2 安裝部署api
2.1 安裝配置nginxbash
2.1.1 安裝nginx網絡
yum install nginx
2.1.2 nginx配置
vi /etc/nginx/con.f/域名.conf
server { listen 80; server_name 域名; root /usr/share/nginx/html/blog; #charset koi8-r; access_log /var/log/nginx/域名.access.log main; error_log /var/log/nginx/域名.error.log; location / { root /usr/share/nginx/html/blog; index index.html index.htm index.php; try_files $uri $uri/ /index.php?$args; } #error_page 404 /404.html; # redirect server error pages to the static page /50x.html # error_page 500 502 503 504 /50x.html; location = /50x.html { root /usr/share/nginx/html/blog; } # proxy the PHP scripts to Apache listening on 127.0.0.1:80 # #location ~ \.php$ { # proxy_pass http://127.0.0.1; #} # pass the PHP scripts to FastCGI server listening on 127.0.0.1:9000 # location ~ \.php$ { root /usr/share/nginx/html/blog; fastcgi_pass 127.0.0.1:9000; fastcgi_index index.php; fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name; include fastcgi_params; } # deny access to .htaccess files, if Apache's document root # concurs with nginx's one # #location ~ /\.ht { # deny all; #} } |
2.1.3 下載wordpress
下載網址https://cn.wordpress.org/
2.1.4 解壓wordpress
tar zxvf wordpress-4.7.2-zh_CN.tar.gz
mv wordpress /usr/share/nginx/html/blog/
2.2 安裝配置mysql
2.2.1 下載mysql
下載網址https://www.mysql.com/
2.2.2 安裝mysql(二進制)
添加用戶
#useradd mysql
vi /etc/passwd
將/bin/bash改爲/sbin/nologin
解壓包
#tar zxvf mysql-5.7.17-linux-glibc2.5-x86_64.tar
#mv mysql-5.7.17-linux-glibc2.5-x86_64 /usr/local/mysql
#chown mysql. -R /usr/local/mysql/
配置文件
vi /etc/my.cnf
[client] port = 3306 socket = /usr/local/mysql/tmp/mysql.sock [mysqld] server_id=10 port = 3306 user = mysql socket = /usr/local/mysql /tmp/mysql.sock basedir = /usr/local/mysql datadir = /usr/local/mysql/data pid-file = /usr/local/mysql/data/mysql.pid max_connections = 1000 max_connect_errors = 1000 table_open_cache = 1024 max_allowed_packet = 128M open_files_limit = 65535 #####====================================[innodb]============================== innodb_buffer_pool_size = 1024M innodb_file_per_table = 1 innodb_write_io_threads = 4 innodb_read_io_threads = 4 innodb_purge_threads = 2 innodb_flush_log_at_trx_commit = 1 innodb_log_file_size = 512M innodb_log_files_in_group = 2 innodb_log_buffer_size = 16M innodb_max_dirty_pages_pct = 80 innodb_lock_wait_timeout = 30 innodb_data_file_path=ibdata1:1024M:autoextend #####====================================[log]============================== log_error = /usr/local/mysql/log/mysql-error.log slow_query_log = 1 long_query_time = 1 slow_query_log_file = /usr/local/mysql/log/mysql-slow.log sql_mode=ONLY_FULL_GROUP_BY,STRICT_TRANS_TABLES,NO_ZERO_IN_DATE,NO_ZERO_DATE,ERROR_FOR_DIVISION_BY_ZERO,NO_AUTO_CREATE_USER,NO_ENGINE_SUBSTITUTION |
初始化mysql
cd /usr/local/mysql
mkdir data
mkdir tmp
mkdir log
chown mysql. –R /usr/local/mysql
./bin/mysqld --initialize --user=mysql --basedir=/usr/local/mysql --datadir=/usr/local/mysql/data
若是配置了my.cnf的log_error,那麼初始密碼在log_error文件中,不然會打印出來。
cp support-files/mysql.server /etc/init.d/mysql
chmod +x /etc/init.d/mysql
啓動mysql
/etc/init.d/mysql start
修改密碼
mysql –uroot –p 登陸mysql
SET PASSWORD=PASSWORD('newpassword');
2.3 安裝配置PHP
2.3.1 下載PHP
下載網址http://www.php.net/
2.3.2 安裝PHP
解壓php
tar zxvf php-5.6.30.tar.gz
編譯php
cd php-5.6.30
./configure --prefix=/data/php5 --with-curl --with-freetype-dir --with-gd --with-gettext --with-iconv-dir --with-kerberos --with-libdir=lib64 --with-libxml-dir --with-mysqli --with-openssl --with-pcre-regex --with-pdo-mysql --with-pdo-sqlite --with-pear --with-png-dir --with-xmlrpc --with-xsl --with-zlib --enable-fpm --enable-bcmath --enable-libxml --enable-inline-optimization --enable-gd-native-ttf --enable-mbregex --enable-mbstring --enable-opcache --enable-pcntl --enable-shmop --enable-soap --enable-sockets --enable-sysvsem --enable-xml --enable-zip
make & make install
cp php.ini-production /data/php5/lib/php.ini
cp ./sapi/fpm/init.d.php-fpm /etc/init.d/php-fpm
chmod +x /etc/init.d/php-fpm
cd /data/php5/etc
cp php-fpm.conf.default php-fpm.conf
安裝mysql擴展
cd php-5.6.30
cd ext/mysql
/data/php5/bin/phpize
./configure --with-php-config=/data/php5/bin/php-config
make & make install
修改配置文件
vi /data/php5/lib/php.ihi
修改以下配置:
default_charset = "UTF-8"
error_log = /opt/php5/var/log/php_errors.log
upload_max_filesize = 32M
upload_tmp_dir = /opt/php5/var/tmp
date.timezone="Asia/Shanghai"
extension=mysql.so
vi /data/php5/etc/php-fpm.conf
修改以下配置:
user = webuser
group = webuser
啓動php
/etc/init.d/php-fpm start
2.3.3 測試php
vi test.php
<?php phpinfo(); ?> |
mv test.php /usr/share/nginx/html/blog
訪問http://域名/test.php
2.4 安裝wordpress
mysql –uroot –p
create database wordpress;
訪問http://域名/