centos6.6编译安装LNMP+WordPress配置伪静态

2023年 7月 15日 85.6k 0

systeminfoOS:centos6.6mysql:5.6.14二进制包nginx:1.6.3php:5.3.271,install mysql 二进制mysql安装

mkdir -pv /mydata/data
groupadd -r -g 306 mysql
useradd -r -g 306 -u 306 mysql
chown -R mysql.mysql /mydata
tar xf tar xf mysql-5.6.14-linux-glibc2.5-x86_64.tar.gz 
cd /usr/local
ln -s mysql-5.6.14-linux-glibc2.5-x86_64 mysql
cd mysql/
chown -R root.mysql ./*
scripts/mysql_install_db --user=mysql --datadir=/mydata/data
mkdir /etc/mysql
cp support-files/my-default.cnf /etc/mysql/my.cnf

修改配置文件

vim  /etc/mysql/my.cnf
datadir=/mydata/data
innodb_file_per_table = on
skip_name_resolve = on
port = 3306
socket = /tmp/mysql.sock

复制脚本

cp support-files/mysql.server /etc/init.d/mysqld
chmod 755 /etc/init.d/mysqld
chkconfig --add mysqld
service mysqld start

环境变量修改

vim  /etc/profile.d/mysql.sh
export PATH=/usr/local/mysql/bin:$PATH
. /etc/profile.d/mysql.sh

2,install nginx安装依赖包

yum -y install pcre pcre-devel
http://nginx.org/download/nginx-1.6.3.tar.gz
groupadd -r nginx
useradd -g nginx -r nginx

编译

 ./configure 
--prefix=/usr/local/nginx 
--conf-path=/etc/nginx/nginx.conf 
--user=nginx --group=nginx 
--error-log-path=/var/log/nginx/error.log 
--http-log-path=/var/log/nginx/access.log 
--pid-path=/var/run/nginx/nginx.pid 
--lock-path=/var/lock/nginx.lock 
--with-http_ssl_module 
--with-http_stub_status_module 
--with-http_gzip_static_module 
--with-http_flv_module 
--with-http_mp4_module 
--http-client-body-temp-path=/var/tmp/nginx/client 
--http-proxy-temp-path=/var/tmp/nginx/proxy 
--http-fastcgi-temp-path=/var/tmp/nginx/fastcgi 
--http-uwsgi-temp-path=/var/tmp/nginx/uwsgi
make && make install
mkdir -pv /var/tmp/nginx/{client,fastcgi,proxy,uwsgi}
/usr/local/sbin/nginx

3,install php编译libiconv

cd /usr/local/
wget http://ftp.gnu.org/pub/gnu/libiconv/libiconv-1.14.tar.gz
tar zxf libiconv-1.14.tar.gz
cd libiconv-1.14
./configure --prefix=/usr/local/libiconv

make
make install

安装依赖

wget http://ftp.ntu.edu.tw/php/distributions/php-5.3.27.tar.gz
 yum install -y libxml2-devel openssl openssl-devel bzip2 bzip2-devel libpng libpng-devel freetype freetype-devel libcurl-devel libcurl libjpeg libjpeg-devel libpng libpng-devel freetype freetype-devel libmcrypt-devel libmcrypt libtool-ltdl-devel libxslt-devel mhash mhash-devel

ln -s ln -s /usr/local/mysql/lib/libmysqlclient.so.18 /usr/lib64/
touch ext/phar/phar.phar

报错

#####MySQLdb ImportError: libmysqlclient.so.18######
#    echo "/usr/local/mysql/lib" >>/etc/ld.so.conf  
#    ldconfig                                       
####################################################

编译

./configure 
 --prefix=/usr/local/php5.3 
 --with-mysql=/usr/local/mysql 
 --with-iconv-dir=/usr/local/libiconv 
 --with-freetype-dir 
 --with-jpeg-dir 
 --with-png-dir 
 --with-zlib 
 --with-libxml-dir=/usr 
 --enable-xml 
 --disable-rpath 
 --enable-safe-mode 
 --enable-bcmath 
 --enable-shmop 
 --enable-sysvsem 
 --enable-inline-optimization 
 --with-curl 
 --with-curlwrappers 
 --enable-mbregex 
 --enable-fpm 
 --enable-mbstring 
 --with-mcrypt 
 --with-gd 
 --enable-gd-native-ttf 
 --with-openssl 
 --with-mhash 
 --enable-pcntl 
 --enable-sockets 
 --with-xmlrpc 
 --enable-zip 
 --enable-soap 
 --enable-short-tags 
 --enable-zend-multibyte 
 --enable-static 
 --with-xsl 
 --with-fpm-user=nginx 
 --with-fpm-group=nginx 
 --enable-ftp 

其他需要mysql库的php

 --with-mysql=mysqlnd 
 --with-mysqli=mysqlnd 
 --with-pdo-mysql=mysqlnd 

复制配置文件

 cp /usr/local/php5.3.27/php.ini-production /usr/local/php5.3/lib/php.ini
 cp /usr/local/php5.3/etc/php-fpm.conf.default /usr/local/php5.3/etc/php-fpm.conf

修改配置文件

vim /usr/local/php5.3/etc/php-fpm.conf
pid = run/php-fpm.pid
error_log = /phplog/php-fpm.log
log_level = error
rlimit_files = 32768 ;文件描述符
events.mechanism = epoll ;开启epoll模型
listen.owner = nginx
listen.group = nginx
pm.max_children = 1024          pm被设为静态可以被创建的子进程数量
pm.start_servers = 16            启动的进程
pm.min_spare_servers = 5          空闲
pm.max_spare_servers = 20        最大空闲
pm.process_idle_timeout = 15s    空闲超时时间
pm.max_requests = 2048            每个子进程最大的请求
slowlog = /phplog/$pool.log.slow
request_slowlog_timeout = 10
php_admin_value[sendmail_path] = /usr/sbin/sendmail -t -i -f 734943463@qq.com 

[root@NFS-WEB1 php-5.3.27]# mkdir /phplog

查看启动情况

[root@NFS-WEB1 php-5.3.27]# ps -ef|grep php-fpm
root       2834      1  0 07:03 ?        00:00:00 php-fpm: master process (/usr/local/php5.3/etc/php-fpm.conf)
nginx      2835   2834  0 07:03 ?        00:00:00 php-fpm: pool www             
nginx      2836   2834  0 07:03 ?        00:00:00 php-fpm: pool www             
nginx      2837   2834  0 07:03 ?        00:00:00 php-fpm: pool www             
nginx      2838   2834  0 07:03 ?        00:00:00 php-fpm: pool www             
nginx      2839   2834  0 07:03 ?        00:00:00 php-fpm: pool www             
nginx      2840   2834  0 07:03 ?        00:00:00 php-fpm: pool www             
nginx      2841   2834  0 07:03 ?        00:00:00 php-fpm: pool www             
nginx      2842   2834  0 07:03 ?        00:00:00 php-fpm: pool www             
nginx      2843   2834  0 07:03 ?        00:00:00 php-fpm: pool www             
nginx      2844   2834  0 07:03 ?        00:00:00 php-fpm: pool www             
nginx      2845   2834  0 07:03 ?        00:00:00 php-fpm: pool www             
nginx      2846   2834  0 07:03 ?        00:00:00 php-fpm: pool www             
nginx      2847   2834  0 07:03 ?        00:00:00 php-fpm: pool www             
nginx      2848   2834  0 07:03 ?        00:00:00 php-fpm: pool www             
nginx      2849   2834  0 07:03 ?        00:00:00 php-fpm: pool www             
nginx      2850   2834  0 07:03 ?        00:00:00 php-fpm: pool www             
root       2852   1946  0 07:03 pts/1    00:00:00 grep php-fpm
[root@NFS-WEB1 php-5.3.27]# ss -lntup|grep php-fpm
tcp    LISTEN     0      128            127.0.0.1:9000                  *:*      users:(("php-fpm",2834,7),("php-fpm",2835,0),("php-fpm",2836,0),("php-fpm",2837,0),("php-fpm",2838,0),("php-fpm",2839,0),("php-fpm",2840,0),("php-fpm",2841,0),("php-fpm",2842,0),("php-fpm",2843,0),("php-fpm",2844,0),("php-fpm",2845,0),("php-fpm",2846,0),("php-fpm",2847,0),("php-fpm",2848,0),("php-fpm",2849,0),("php-fpm",2850,0))
[root@NFS-WEB1 php-5.3.27]# 

4,配置安装wordpress

https://cn.wordpress.org/wordpress-4.4.1-zh_CN.zip
unzip wordpress-4.4.1-zh_CN.zip

将文件复制到虚拟目录下后修改blog.conf

server {
        listen          80;
        server_name www.linuxea.com;
        location / {
            root  /www/blog;
            index index.php index.html index.htm;
        }
        location ~ .*. (php|php5.3.27)?$ {
                root html/blog;
                fastcgi_pass 127.0.0.1:9000;
                fastcgi_index index.php;
                include fastcgi.conf;
        }
        }

创建相应目录

mkdir -p /usr/local/nginx/logs/
mkdir /www/blog

启动

/usr/local/php5.3/sbin/php-fpm
/usr/local/nginx/sbin/nginx -s reload
/etc/init.d/mysqld start

测试php

vim /www/blog/phpinfo.php
<?php
phpinfo();
?>

QQ截图20160114215447.png

数据库授权

CREATE DATABASE wordpress  CHARACTER SET utf8;
GRANT ALL ON wordpress.* TO 'blog'@'10.0.0.53' IDENTIFIED BY 'password.com';
GRANT ALL ON wordpress.* TO 'blog'@'localhost' IDENTIFIED BY 'password.com';
FLUSH privileges;

数据库测试文件

vim /www/blog/sqlconnect.php
<?
    $link_id=mysql_connect('localhost','blog','password.com') or mysql_error();
    if($link_id){
        echo "mysql successful by LinuxEA!";
    }else{
        echo mysql_error();
    }

?>

mysqltest.png修改wordpress权限

chown -R root.root blog/
find ./blog/ -type d|xargs chmod 755
find ./blog/ -type f|xargs chmod 644
mkdir blog/wp-content/uploads
chown -R nginx.nginx blog/wp-content/uploads/
/usr/local/nginx/sbin/nginx -s reload

打开浏览器测试wordpress.png

伪静态配置

/archives/%post_id%.html

伪静态.png伪静态配置文件修改

server {
        listen          80;
        server_name www.linuxea.com;
        location / {
            root  /www/blog;
            index index.php index.html index.htm;
        location / {
        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;
        }
        }    
        }
        location ~ .*. (php|php5.3.27)?$ {
                root html/blog;
                fastcgi_pass 127.0.0.1:9000;
                fastcgi_index index.php;
                include fastcgi.conf;
        }
        }

修改后的伪静态.png

相关文章

LeaferJS 1.0 重磅发布:强悍的前端 Canvas 渲染引擎
10分钟搞定支持通配符的永久有效免费HTTPS证书
300 多个 Microsoft Excel 快捷方式
一步步配置基于kubeadmin的kubevip高可用
istio全链路传递cookie和header灰度
REST Web 服务版本控制

发布评论