Centos6.9实现基于源码编译安装LAMP(FPM模块方式)的wordpress应用

来源:互联网 发布:淘宝店铺主题风格手机 编辑:程序博客网 时间:2024/06/05 22:51
实现上述应用需要用到以下几个软件:

可移植运行库:apr-1.6.2.tar.gz apr-util-1.6.0.tar.gz
网站程序:httpd-2.4.27.tar.bz2
超文本处理器:php-5.6.31.tar.xz
缓存器/优化器:xcache-3.2.0.tar.bz2
数据库:mariadb-5.5.57-linux-x86_64.tar.gz
网站源码程序:wordpress-4.8.1-zh_CN.tar.gz

1 编译http2.4
安装基础依赖组件yum groupinstall "development tools"yum install openssl-devel pcre-devel expat-devel解压缩各包组tar xvf apr-1.6.2.tar.gz tar xvf apr-util-1.6.0.tar.gz tar xvf httpd-2.4.27.tar.bz2 cp -r apr-1.6.2 httpd-2.4.27/srclib/aprcp -r apr-util-1.6.0 httpd-2.4.27/srclib/apr-util编译安装cd httpd-2.4.27/        #进入httpd目录,运行以下命令./configure --prefix=/app/httpd24 \--enable-so --enable-ssl \--enable-rewrite \--with-zlib \--with-pcre \--with-included-apr \--enable-modules=most \--enable-mpms-shared=all \--with-mpm=prefork#运行完之后看是否有错误提示,如果有需要安装的依赖包组,再安装过后,重新运行以上命令make -j 2 && make install在/etc/profile.d创建lamp脚本,将httpd/bin目录加入到系统变量cat > /etc/profile.d/lamp.sh << eofPATH=/app/httpd24/bin/:$PATHeof. /etc/profile.d/lamp.shcp /etc/init.d/httpd /etc/init.d/httpd24vim /etc/init.d/httpd24apachectl=/app/httpd24/bin/apachectlhttpd=${HTTPD-/app/httpd24/bin/httpd}prog=httpdpidfile=${PIDFILE-/app/httpd24/logs/httpd.pid}lockfile=${LOCKFILE-/var/lock/subsys/httpd24}添加服务chkconfig --add httpd24chkconfig --listservice httpd24 start
2 二进制安装mariadb
tar xvf mariadb-5.5.57-linux-x86_64.tar.gz  -C /usr/local/  #数据库安装解压的路径为指定路径ln -s mariadb-5.5.57-linux-x86_64/ mysql新建mysql系统账户useradd -r -m -d /app/mysqldb -s /sbin/nologin mysql cd mysql/scripts/mysql_install_db --datadir=/app/mysqldb --user=mysqlmkdir /etc/mysqlcp support-files/my-large.cnf   /etc/mysql/my.cnf

修改配置文件
vim /etc/mysql/my.cnf
[mysqld]
datadir = /app/mysqldb
innodb_file_per_table = ON
skip_name_resolve = ON

cp support-files/mysql.server /etc/init.d/mysqld   #添加mysqld服务脚本chkconfig --add mysqld                              #添加服务chkconfig --list touch /var/log/mysqld.log                           #创建日志文件chown mysql /var/log/mysqld.log                     #给日志文件夹写权限service mysqld startcat > /etc/profile.d/lamp.sh << eof                 #添加环境变量PATH=/app/httpd24/bin/:/usr/local/mysql/bin/:$PATHeof#初始化数据库安全环境mysql_secure_installation#设置访问类型mysql -uroot -pcentoscreate datebase wpdb;grant all on wpdb.* to wpuser@'192.168.25.%' identified by 'centos';grant all on wpdb.* to wpuser@'127.%' identified by 'centos';grant all on wpdb.* to wpuser@'localhost' identified by 'centos';
3 源码编译php
yum install libxml2-devel bzip2-devel libmcrypt-devel   #安装必要的组件tar xvf php-5.6.31.tar.xzcd php-5.6.31./configure \--prefix=/app/php5 \--with-mysql=/usr/local/mysql \--with-openssl \--with-mysqli=/usr/local/mysql/bin/mysql_config \--enable-mbstring \--with-freetype-dir  \--with-jpeg-dir \--with-png-dir \--with-zlib \--with-libxml-dir=/usr \--enable-xml \--enable-sockets \--enable-fpm \--with-mcrypt \--with-config-file-path=/etc/php5 \--with-config-file-scan-dir=/etc/php5.d \--with-bz2make -j 2 && make install#添加环境变量vi /etc/profile.d/lamp.sh PATH=/app/php5/bin:/app/httpd24/bin/:/usr/local/mysql/bin/:$PATH.  /etc/profile.d/lamp.sh mkdir /etc/php5/cp php.ini-production /etc/php5/php.inicp   sapi/fpm/init.d.php-fpm /etc/init.d/php-fpmchmod +x /etc/init.d/php-fpmchkconfig --add php-fpmchkconfig --list  php-fpmcd /app/php5/etccp php-fpm.conf.default php-fpm.confvim /app/httpd24/conf/httpd.conf取消两行的注释LoadModule proxy_module modules/mod_proxy.soLoadModule proxy_fcgi_module modules/mod_proxy_fcgi.so在文件尾部加四行AddType application/x-httpd-php .phpAddType application/x-httpd-php-source .phpsProxyRequests Off 关闭正向代理ProxyPassMatch  ^/(.*\.php)$ fcgi://127.0.0.1:9000/app/httpd24/htdocs/$1修改下面行<IfModule dir_module>    DirectoryIndex index.php index.html</IfModule>service httpd24 restartservice php-fpm start
4 测试
5 配置wordpress
tar xvf wordpress-4.8.1-zh_CN.tar.gz  -C /app/httpd24/htdocscd /app/httpd24/htdocsmv wordpress/ blog/cd /app/httpd24/htdocs/blog/cp wp-config-sample.php  wp-config.phpvim wp-config.phpdefine('DB_NAME', 'wpdb');/** MySQL数据库用户名 */define('DB_USER', 'wpuser');/** MySQL数据库密码 */define('DB_PASSWORD', 'centos');/** MySQL主机 */define('DB_HOST', 'localhost');
6 登录测试
http://websrv/blog 测试性能ab -c 10 -n 100 http://websrv/blog/7 编译xcache 实现Php加速tar xvf xcache-3.2.0.tar.bz2 cd xcache-3.2.0phpize ./configure  --enable-xcache --with-php-config=/app/php5/bin/php-config make && make installmkdir /etc/php.d/cp xcache.ini  /etc/php5.d/vim /etc/php5.d/xcache.ini extension = /app/php5/lib/php/extensions/no-debug-non-zts-20131226/xcache.soservice php-fpm restart8 8 测试ab -c 10 -n 100 http://websrv/blog/
原创粉丝点击