首页 > 代码库 > LNMP搭建wordpress
LNMP搭建wordpress
LNMP搭建wordpress
[root@lvs2 wordpress]# uname -a
Linux lvs2 2.6.32-358.el6.x86_64 #1 SMP Fri Feb 22 00:31:26 UTC 2013 x86_64 x86_64 x86_64 GNU/Linux
[root@lvs2 wordpress]#service iptables stop
# cat /etc/sysconfig/selinux
SELINUX=disabled
安装gcc编译器及相关工具和依赖库:
[root@rj20140917 ~]# yum -y install gcc gcc-c++ autoconf libjpeg libjpeg-devel libpng libpng-devel freetype freetype-devel libxml2 libxml2-devel zlib zlib-devel glibc glibc-devel glib2 glib2-devel bzip2 bzip2-devel ncurses ncurses-devel curl curl-devel e2fsprogs e2fsprogs-devel krb5 krb5-devel libidn libidn-devel openssl openssl-devel openldap openldap-devel nss_ldap openldap-clients openldap-servers
创建一个指定放置压缩包的目录
#mkdir -p /rj20140917
[root@lvs2 wordpress]# ls /rj20140912/
cmake-2.8.12.2 libiconv-1.14.tar.gz nginx-1.7.4
cmake-2.8.12.2.tar.gz libmcrypt-2.5.7 nginx-1.7.4.tar.gz
fontconfig-2.11.1 libmcrypt-2.5.7.tar.gz pcre-8.35
fontconfig-2.11.1.tar.gz libpng-1.4.3 pcre-8.35.tar.gz
freetype-2.5.3 libpng-1.4.3.tar.bz2 php-5.5.15
freetype-2.5.3.tar.bz2 libxml2-2.9.1 php-5.5.15.tar.gz
jpeg-9 libxml2-2.9.1.tar.gz wordpress
jpegsrc.v9.tar.gz mysql-5.6.10 wordpress-4.0-zh_CN.tar.gz
libgd-2.1.0 mysql-5.6.10.tar.gz zlib-1.2.8
libgd-2.1.0.tar.gz ncurses-5.9 zlib-1.2.8.tar.gz
libiconv-1.14 ncurses-5.9.tar.gz
[root@lvs2 wordpress]#
下载以上包文件:
http://ftp.cs.stanford.edu/pub/exim/pcre/pcre-8.35.tar.gz
http://cn.wordpress.org/wordpress-4.0-zh_CN.tar.gz
https://bbuseruploads.s3.amazonaws.com/libgd/gd-libgd/downloads/libgd-2.1.0.tar.gz?Signature=dZfbHfwjd3ZrnowVsc%2F%2BerlzJv4%3D&Expires=1410838971&AWSAccessKeyId=0EMWEFSGA12Z1HF1TZ82
http://cn2.php.net/distributions/php-5.5.15.tar.gz
http://wwwNaNake.org/files/v3.0/cmake-3.0.2.tar.gz
http://nginx.org/download/nginx-1.7.4.tar.gz
http://ftp.gnu.org/pub/gnu/libiconv/libiconv-1.14.tar.gz
http://xmlsoft.org/sources/libxml2-2.9.1.tar.gz
http://pkgs.fedoraproject.org/repo/pkgs/libmcrypt/libmcrypt-2.5.7.tar.gz/b1be163143f8e8ed0474beeb642b3bad/libmcrypt-2.5.7.tar.gz
http://mirror.mcs.anl.gov/pub/gnu/ncurses/ncurses-5.9.tar.gz
http://zlib.net/zlib-1.2.8.tar.gz
http://pkgs.fedoraproject.org/repo/pkgs/mingw32-libpng/libpng-1.4.3.tar.bz2/9347eeda4241401f7da4dc9ba7f6a416/libpng-1.4.3.tar.bz2
http://www.freedesktop.org/software/fontconfig/release/fontconfig-2.11.1.tar.gz
http://www.ijg.org/files/jpegsrc.v9.tar.gz
编译安装libgd-2.1.0.tar.gz
[root@rj20140917]# tar -zxvf libgd-2.1.0.tar.gz
[root@rj20140917]# cd libgd-2.1.0
[root@rj20140917 libgd-2.1.0]#./configure --prefix=/usr/local/libgd --with-zlib=/usr/local/zlib --with-png=/usr/local/libpng --with-jpeg=/usr/local/jpeg --with-freetype=/usr/local/freetype --with-fontconfig=/usr/local/fontconfig
[root@rj20140917 libgd-2.1.0]# make && make install
编译安装pcre-8.35.tar.gz
[root@rj20140917 ~]# cd /rj20140912/
[root@rj20140917]# tar -zxvf pcre-8.35.tar.gz
[root@rj20140917]# cd pcre-8.35
[root@rj20140917 pcre-8.35]# ./configure --prefix=/usr/local/pcre
[root@rj20140917 pcre-8.35]# make && make install
编译安装freetype-2.5.3.tar.gz
[root@rj20140917]#tar -zxvf freetype-2.5.3.tar.gz
[root@rj20140917]# cd freetype-2.5.3
[root@rj20140917 freetype-2.5.3]#yum install freetype-devel
[root@rj20140917 freetype-2.5.3]#mkdir /usr/local/freetype/include/freetype2/freetype
[root@rj20140917 freetype-2.5.3]#mkdir /usr/local/freetype/include/freetype2/freetype/config
[root@rj20140917 freetype-2.5.3]# ./configure --prefix=/usr/local/freetype
[root@rj20140917 freetype-2.5.3]# make && make install
编译安装jpegsrc.v9.tar.gz
[root@rj20140917]# tar -zxvf jpegsrc.v9.tar.gz
[root@rj20140917]# cd jpeg-9/
[root@rj20140917 jpeg-9]# mkdir /usr/local/jpeg
[root@rj20140917 jpeg-9]# mkdir /usr/local/jpeg/bin
[root@rj20140917 jpeg-9]# mkdir /usr/local/jpeg/lib
[root@rj20140917 jpeg-9]# mkdir /usr/local/jpeg/include
[root@rj20140917 jpeg-9]# mkdir /usr/local/jpeg/man
[root@rj20140917 jpeg-9]# mkdir /usr/local/jpeg/man/man1
[root@rj20140917 jpeg-9]# ./configure --prefix=/usr/local/jpeg --with-freetype=/usr/local/freetype --enable-shared --enable-static
[root@rj20140917 jpeg-9]# make && make install
编译安装fontconfig-2.11.1.tar.gz
[root@rj20140917]#tar -zxvf fontconfig-2.11.1.tar.gz
[root@rj20140917]# cd fontconfig-2.11.1
[root@rj20140917ontconfig-2.11.1]#../configure--prefix=/usr/local/fontconfig --with-freetype-config=/usr/local/freetype/bin/freetype-config --with-expat-lib=/usr/lib64
[root@rj20140917 fontconfig-2.11.1]#make && make install
编译安装libpng-1.4.3.tar.bz2
[root@rj20140917]# tar -jvxf libpng-1.4.3.tar.bz2
[root@rj20140917]# cd libpng-1.4.3
[root@rj20140917 libpng-1.4.3]# ./configure --prefix=/usr/local/libpng --enable-static --enable-shared
[root@rj20140917 libpng-1.4.3]# make && make install
编译安装 zlib-1.2.8.tar.gz
[root@rj20140917]# tar -zxvf zlib-1.2.8.tar.gz
[root@rj20140917]# cd zlib-1.2.8
[root@rj20140917 zlib-1.2.8]# ./configure --prefix=/usr/local/zlib
[root@rj20140917 zlib-1.2.8]# make && make install
编译安装ncurses-5.9.tar.gz
[root@rj20140917]# tar -zxvf ncurses-5.9.tar.gz
[root@rj20140917]# cd ncurses-5.9
[root@rj20140917 ncurses-5.9]# ./configure --prefix=/usr/local/ncurses
[root@rj20140917 ncurses-5.9]# make && make install
编译安装libmcrypt-2.5.7.tar.gz
[root@rj20140917]# tar -zxvf libmcrypt-2.5.7.tar.gz
[root@rj20140917 libmcrypt-2.5.7]# ./configure --prefix=/usr/local/libmcrypt --enable-shared --enable-static --enable-dynamic-loading
[root@rj20140917 libmcrypt-2.5.7]# make && make install
编译安装libxml2-2.9.1.tar.gz
[root@rj20140917]# tar -zxvf libxml2-2.9.1.tar.gz
[root@rj20140917]# cd libxml2-2.9.1
#yum install libxml2-dev libxml2* libxslt* libxml.lo
[root@rj20140917 libxml2-2.9.1]# ./configure --prefix=/usr/local/libxml2 --enable-shared --enable-static
[root@rj20140917 libxml2-2.9.1]# make && make install
编译安装libiconv-1.14.tar.gz
[root@rj20140917]# tar -zxvf libiconv-1.14.tar.gz
[root@rj20140917]# cd libiconv-1.14
[root@rj20140917 libiconv-1.14]# ./configure --prefix=/usr/local/libiconv
[root@rj20140917 libiconv-1.14]# make && make install
安装nginx
[root@rj20140917]# useradd -s /sbin/nologin -M nginx
[root@rj20140917]# groupadd ngnix
[root@rj20140917]# ttar -zxvf nginx-1.7.4.tar.gz
[root@rj20140917]# cd nginx-1.7.4
[root@rj20140917 nginx-1.7.4]#./configure --user=nginx --group=nginx --prefix=/usr/local/nginx --with-http_stub_status_module --with-http_ssl_module --with-pcre=/rj20140912/pcre-8.35
[root@rj20140917 nginx-1.7.4]# make && make install
[root@rj20140917 nginx-1.7.4]# ln -s /usr/local/nginx-1.7.4 /usr/local/nginx
[root@rj20140917 nginx-1.7.4]# /usr/local/nginx/sbin/nginx -t
nginx: the configuration file /usr/local/nginx-1.7.4/conf/nginx.conf syntax is ok
nginx: configuration file /usr/local/nginx-1.7.4/conf/nginx.conf test is successful
[root@rj20140917 nginx-1.7.4]# netstat -anpt | grep nginx
[root@rj20140917 nginx-1.7.4]# ps -ef | grep nginx
#chkconfig --add nginx
#chkconfig --level 345 nginx on
安装cmake
#rpm -qa | grep mysql
#yum remove mysql* -y
#tar -zxvf cmake-2.8.12.2.tar.gz
#cd cmake-2.8.12.2
#./bootstrap
#make && make install
安装mysql
[root@rj20140917]# groupadd mysql
[root@rj20140917]# useradd -s /sbin/nologin -g mysql -M mysql
[root@rj20140917]# tar -zxvf mysql-5.6.10.tar.gz
[root@rj20140917]# cd mysql-5.6.10
[root@rj20140917mysql-5.6.10]#cmake-DCMAKE_INSTALL_PREFIX=/usr/local/mysql -DWITH_INNOBASE_STORAGE_ENGINE=1-DWITH_MEMORY_STORAGE_ENGINE=1 -DWITH_MYISAM_STORAGE_ENGINE=1-DSYSCONFDIR=/etc/-DDEFAULT_CHARSET=utf8 -DDEFAULT_COLLATION=utf8_general_ci -DWITH_READLINE=on -DWITH_SSL=yes
[root@rj20140917 mysql-5.6.10]# make && make install
[root@rj20140917 mysql-5.6.10]# cp support-files/my-default.cnf /etc/my.cnf
[root@rj20140917 mysql-5.6.10]# ln -s /usr/local/mysql/lib/lib* /usr/lib64/
[root@rj20140917 mysql-5.6.10]#
[root@rj20140917mysql-5.6.10]#./scripts/mysql_install_db--basedir=/usr/local/mysql/-datadir=/usr/local/mysql/data/mysql/ --user=mysql
[root@rj20140917 mysql-5.6.10]# cp support-files/mysql.server /etc/init.d/mysqld
[root@rj20140917 mysql-5.6.10]#
[root@rj20140917 mysql-5.6.10]# chown -R root.mysql /application/mysql/bin/mysql
[root@rj20140917 mysql-5.6.10]#
[root@rj20140917 mysql-5.6.10]# ldconfig
[root@rj20140917 mysql-5.6.10]#
[root@rj20140917 mysql-5.6.10]# netstat -anpt | grep mysqld
[root@rj20140917 mysql-5.6.10]# chmod +x /etc/init.d/mysqld
[root@rj20140917 mysql-5.6.10]# chkconfig --add mysqld
[root@rj20140917 mysql-5.6.10]# chkconfig --level 345 mysqld on
[root@rj20140917 mysql-5.6.10]# service mysqld start
[root@rj20140917 mysql-5.6.10]# ln -s /usr/local/mysql/bin/mysql /bin
[root@rj20140917 mysql-5.6.10]# ./bin/mysql_secure_installation
[root@rj20140917 mysql-5.6.10]# mysql -u root -p
#lsof -n | grep tcmalloc
#yum -y install autoconf libjpeg libjpeg-devel libpng libpng-devel freetype freetype-devel libxml2 libxml2-devel zlib zlib-devel glibc glibc-devel glib2 glib2-devel bzip2 bzip2-devel ncurses ncurses-devel curl curl-devel e2fsprogs e2fsprogs-devel krb5 krb5-devel libidn libidn-devel openssl openssl-devel openldap openldap-devel nss_ldap openldap-clients openldap-servers libXpm* gcc gcc-c++
安装php
[root@rj20140917]# tar -zxvf php-5.5.15.tar.gz
#cd php-5.5.15
[root@rj20140917 php-5.5.15]# ./configure --prefix=/usr/local/php --with-mysql=/usr/local/mysql --with-xmlrpc --with-openssl --with-zlib --with-freetype-dir=/usr/local/freetype --with-gd=/usr/local/libgd --with-jpeg-dir=/usr/local/jpeg --with-png-dir=/usr/local/libpng --with-iconv=/usr/local/libiconv --enable-short-tags --enable-sockets --enable-zend-multibyte --enable-soap --enable-mbstring --enable-static --enable-gd-native-ttf --with-curl --with-xsl --enable-ftp --with-libxml-dir=/usr/local/libxml2 --enable-gd-native-ttf --enable-zip --enable-fastcgi --enable-fpm
[root@rj20140917 php-5.5.15]# make && make install
配置php-fpm:
[root@rj20140917 php-5.5.15]# cd /usr/local/php/etc/
[root@rj20140917 etc]# cp php-fpm.conf.default php-fpm.conf
[root@rj20140917 etc]# egrep -v ";|^$" php-fpm.conf
[global]
error_log = /var/log/php-fpm.log
log_level = notice
pid = /var/log/php/php-fpm.pid
[www]
user = nginx
group = nginx
listen = 127.0.0.1:9000
pm = dynamic
pm.max_children = 50
pm.start_servers = 20
pm.min_spare_servers = 5
pm.max_spare_servers = 35
[root@rj20140917 etc]# mkdir /var/log/php
[root@rj20140917 etc]# ../sbin/php-fpm
[root@rj20140917 etc]# ps -ef | grep php-fpm
[root@rj20140917 local]# vim /usr/local/nginx/conf/nginx.conf
user nginx nginx;
worker_processes 8;
#error_log logs/error.log;
#error_log logs/error.log notice;
#error_log logs/error.log info;
error_log /app/logs/nginx_error.log crit;
#pid logs/nginx.pid;
events {
worker_connections 1024;
}
http {
include mime.types;
default_type application/octet-stream;
log_format commonlog ‘$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 main;
sendfile on;
#tcp_nopush on;
#keepalive_timeout 0;
keepalive_timeout 65;
#gzip on;
server {
listen 80;
server_name www.beyond.com;
#charset koi8-r;
#access_log logs/host.access.log main;
location / {
root /data/www/www;
index index.php index.html index.htm;
}
#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 html;
}
location ~ .*\.(php|php5)?$ {
root /data/www/www;
fastcgi_pass 127.0.0.1:9000;
fastcgi_index index.php;
fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
include fastcgi_params;
}
#mkdir /app
#mkdir /app/logs
[root@rj20140917 local]# /usr/local/nginx/sbin/nginx -t
nginx: the configuration file /usr/local/nginx-1.7.4/conf/nginx.conf syntax is ok
nginx: configuration file /usr/local/nginx-1.7.4/conf/nginx.conf test is successful
[root@rj20140917 local]# /usr/local/nginx/sbin/nginx -s reload
#cp /rj20140912/php-5.5.15/php.ini-production /usr/local/php/
#cp php.ini-production php.ini
[root@rj20140917 php-5.5.15]# grep short_open_tag /usr/local/php/php.ini
; short_open_tag
short_open_tag = On
测试下php和数据库是否成功
[root@rj20140917 www]# cat test.php
<?
phpinfo();
?>
[root@rj20140917 www]# cat testdb.php
<?php
$link=mysql_connect(‘localhost‘,‘root‘,‘‘);
if ($link)
echo "successful";
else
echo "Faile";
mysql_close();
?>
[root@rj20140917 nginx]#/usr/local/nginx/sbin/nginx -s reload
#mkdir /data
#mkdir /data/www
#chmod 755 /data/www
#cd /data/www
#tar -zxvf wordpress-4.0-zh_CN.tar.gz
#cp -R wordpress /data/www/
#/usr/local/nginx/sbin/nginx -s reload
本文出自 “雨路良木子” 博客,请务必保留此出处http://yllmz.blog.51cto.com/946423/1553689
LNMP搭建wordpress