前言 最近沒更新新篇幅了,今天就來點幹活,過多的也不說了下麵著手乾!乾!乾! 準備環境 centos7.5 apr-1.6.3.tar.gz apr-util-1.6.1.tar.gz httpd-2.4.34.tar.bz2 php-7.1.18.tar.bz2 mariadb-10.2.16-l ...
前言
最近沒更新新篇幅了,今天就來點幹活,過多的也不說了下麵著手乾!乾!乾!
準備環境
centos7.5
apr-1.6.3.tar.gz
apr-util-1.6.1.tar.gz
httpd-2.4.34.tar.bz2
php-7.1.18.tar.bz2
mariadb-10.2.16-linux-x86_64.tar.gz
wordpress-4.9.4-zh_CN.tar.gz
編譯HTTP
1、安裝包組以及相關包
yum groupinstall "development tools" yum install pcre-devel openssl-devel expat-devel
2、創建用戶與解壓
useradd -r -s /sbin/nologin apache tar xf httpd-2.4.34.tar.bz2 tar xf apr-1.6.3.tar.gz tar xf apr-util-1.6.1.tar.gz
3、移動apr目錄
mv apr-1.6.3 httpd-2.4.34/srclib/apr mv apr-util-1.6.1 httpd-2.4.34/srclib/apr-util
4、源碼編譯
cd httpd-2.4.34/ ./configure --prefix=/app/httpd24 \ --enable-so \ --enable-ssl \ --enable-cgi \ --enable-rewrite \ --with-zlib \ --with-pcre \ --enable-modules=most \ --enable-mpms-shared=all \ --with-mpm=prefork \ --with-included-apr make && make install
5、設置環境變數
echo 'PATH=/app/httpd24/bin:$PATH' > /etc/profile.d/lamp.sh
6、編輯配置文件
vim /app/httpd24/conf/httpd.conf user apache group apache 取消下麵註釋 LoadModule proxy_module modules/mod_proxy.so LoadModule proxy_fcgi_module modules/mod_proxy_fcgi.so 在下麵行添加index.php IfModule dir_module> DirectoryIndex index.php index.html </IfModule> 添加子配置文件 Include conf/extra/php.conf
7、編輯子配置文件
vim /app/httpd24/conf/extra/php.conf 添加以下內容 AddType application/x-httpd-php .php AddType application/x-httpd-php-source .phps ProxyRequests Off ProxyPassMatch ^/(.*\.php)$ fcgi://127.0.0.1:9000/app/httpd24/htdocs/$1
8、啟動服務
apachectl
二進位安裝MYSQL
1、在前幾篇里有提到詳細的安裝過程,這裡就直接幹活代碼
useradd -r -s /sbin/nologin mysql tar xvf mariadb-10.2.16-linux-x86_64.tar.gz -C /usr/local/ cd /usr/local/ ln -s mariadb-10.2.16-linux-x86_64/ mysql chown -R mysql.mysql mysql/ mkdir /app/mysql chown mysql.mysql /app/mysql cd /usr/local/mysql/ scripts/mysql_install_db --datadir=/app/mysql --user=mysql mkdir /etc/mysql/ cp support-files/my-huge.cnf /etc/mysql/my.cnf vim /etc/mysql/my.cnf datadir=/app/mysql cp support-files/mysql.server /etc/init.d/mysqld chkconfig --add mysqld chkconfig --list service mysqld start vim /etc/profile.d/lamp.sh PATH=/app/httpd24/bin:/usr/local/mysql/bin:$PATH mysql -e "create database wpdb;grant all on wpdb.* to wpuser@'localhost' identified by 'centos'"
備註:這裡可以跑下mysql安全腳本,做下安全鞏固--請看https://www.cnblogs.com/xsuid/p/9368389.html
PHP編譯安裝
1、安裝包與解壓
yum install libxml2-devel bzip2-devel libmcrypt-devel tar xvf php-7.1.18.tar.bz2
2、源碼編譯
cd php-7.1.18/ ./configure --prefix=/app/php \ --enable-mysqlnd \ --with-mysqli=mysqlnd \ --with-openssl \ --with-pdo-mysql=mysqlnd \ --enable-mbstring \ --with-freetype-dir \ --with-jpeg-dir \ --with-png-dir \ --with-zlib \ --with-libxml-dir=/usr \ --enable-xml \ --enable-sockets \ --enable-fpm \ --with-config-file-path=/etc \ --with-config-file-scan-dir=/etc/php.d \ --enable-maintainer-zts \ --disable-fileinfo make -j 4 && make install
3、環境變數
vim /etc/profile.d/lamp.sh PATH=/app/php/bin:/app/httpd24/bin:/usr/local/mysql/bin:$PATH
4、php設置
cp php.ini-production /etc/php.ini cp sapi/fpm/init.d.php-fpm /etc/init.d/php-fpm PHP配置文件 chmod +x /etc/init.d/php-fpm chkconfig --add php-fpm chkconfig php-fpm on 啟動程式 cd /app/php/etc cp php-fpm.conf.default php-fpm.conf cp php-fpm.d/www.conf.default php-fpm.d/www.conf php fastcgi配置文件,根據情況來更改
5、啟動服務
service php-fpm start
安裝wordpress
tar xvf wordpress-4.9.4-zh_CN.tar.gz
cp -a wordpress/* /app/httpd24/htdocs/
cd /app/httpd24/htdocs/ mv wp-config-sample.php wp-config.php vim wp-config.php
根據上面mysql創建信息更改
附加虛擬主機的實現
編輯文件 vim /etc/httpd/conf.d/vhosts.conf DirectoryIndex index.php <VirtualHost *:80> ServerName www.pma.com DocumentRoot /var/www/html/ ProxyRequests Off ProxyPassMatch ^/(.*\.php)$ fcgi://127.0.0.1:9000/var/www/html/pma/$1 <Directory "/var/www/html"> Require all granted </Directory> </VirtualHost> <VirtualHost *:80> ServerName www.wordpress.com DocumentRoot /var/www/html/ ProxyRequests Off ProxyPassMatch ^/(.*\.php)$ fcgi://127.0.0.1:9000/var/www/html/wordpress/$1 <Directory "/var/www/html"> Require all granted </Directory> </VirtualHost> <VirtualHost *:80> ServerName www.forum.com DocumentRoot /var/www/html/ ProxyRequests Off ProxyPassMatch ^/(.*\.php)$ fcgi://127.0.0.1:9000/var/www/html/forum/$1 <Directory "/var/www/html"> Require all granted </Directory> </VirtualHost>