编译实现基于FASTCGI的LAMP的wordpress

准备环境,两台主机,100做httpd+php,150做mariadb
1、将安装包rz到主机:[root@100 ~]#ls
httpd-2.4.37.tar.bz2 apr-1.6.5.tar.bz2 mariadb-10.2.15-linux-x86_64.tar.gz apr-util-1.6.1.tar.bz2 php-7.3.2.tar.xz wordpress-5.0-zh_CN.zip
[root@100 ~]#tar xf apr-1.6.5.tar.bz2
[root@100 ~]#tar xf httpd-2.4.37.tar.bz2
[root@100 ~]#tar xf php-7.3.2.tar.xz
[root@100 ~]#tar xf apr-util-1.6.1.tar.bz2
2、100主机上:mv apr-1.6.5 httpd-2.4.37/srclib/apr
mv apr-util-1.6.1 httpd-2.4.37/srclib/apr-util
3、一、cd httpd-2.4.37/
二、yum install gcc glibc pcre-devel openssl-devel expat-devel libxml2-devel bzip2-devel libmcrypt-devel
三、./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 -j 4 && make install
4、[root@100 httpd-2.4.37]#echo 'PATH=/app/httpd24/bin:$PATH' > /etc/profile.d/lamp.sh
[root@100 httpd-2.4.37]#. /etc/profile.d/lamp.sh
5、useradd -r -s /sbin/nologin apache
[root@centos7 httpd-2.4.37]#vim /app/httpd24/conf/httpd.conf 此项修改不是必须,主要为了方便查看
User apache
Group apache
6、[root@100 httpd-2.4.37]#apachectl
AH00558: httpd: Could not reliably determine the server's fully qualified domain name, using 0.0.0.100. Set the 'ServerName' directive globally to suppress this message
[root@100 httpd-2.4.37]#ss -ntl
State Recv-Q Send-Q Local Address:Port Peer Address:Port
LISTEN 0 128 :::80 :::*
7、现在我们去centos6上测试:[root@centos6 ~]#curl 192.168.141.100
<html><body><h1>It works!</h1></body></html> 此时说明Apache已经安装成功。
8、150主机上:tar xvf mariadb-10.2.15-linux-x86_64.tar.gz -C /usr/local/
[root@centos7 ~]#cd /usr/local
[root@centos7 local]#ls
bin games lib libexec sbin src
etc include lib64 mariadb-10.2.15-linux-x86_64 share
[root@centos7 local]#ln -s mariadb-10.2.15-linux-x86_64/ mysql
[root@centos7 local]#chown -R root.root /usr/local/mysql/
[root@centos7 local]#ls
bin games lib libexec mysql share etc include lib64 mariadb-10.2.15-linux-x86_64 sbin src
[root@centos7 local]#cd mysql/
[root@centos7 mysql]#ls
bin data lib README-wsrep support-files
COPYING EXCEPTIONS-CLIENT man scripts
COPYING.thirdparty include mysql-test share
CREDITS INSTALL-BINARY README.md sql-bench
[root@centos7 mysql]#mkdir /etc/mysql/
[root@centos7 mysql]#cp support-files/my-huge.cnf /etc/mysql/my.cnf
9、[root@centos7 mysql]#vim /etc/mysql/my.cnf
[mysqld]
datadir=/data/mysql
port = 3306
socket = /tmp/mysql.sock
skip-external-locking
key_buffer_size = 384M
max_allowed_packet = 1M
table_open_cache = 512
sort_buffer_size = 2M
read_buffer_size = 2M
read_rnd_buffer_size = 8M
myisam_sort_buffer_size = 64M
thread_cache_size = 8
query_cache_size = 32M
10、[root@centos7 mysql]#chown mysql.mysql /data/mysql
[root@centos7 mysql]#ll /data/mysql
total 0
[root@centos7 mysql]#ls
bin data lib README-wsrep support-files
COPYING EXCEPTIONS-CLIENT man scripts
COPYING.thirdparty include mysql-test share
CREDITS INSTALL-BINARY README.md sql-bench
[root@centos7 mysql]#scripts/mysql_install_db --datadir=/data/mysql --user=mysql
Installing MariaDB/MySQL system tables in '/data/mysql' ...
2019-03-04 17:09:17 140578725427008 [Warning] 'THREAD_CONCURRENCY' is deprecated and will be removed in a future release.
2019-03-04 17:09:17 140578724841216 [Warning] Failed to load slave replication state from table mysql.gtid_slave_pos: 1146: Table 'mysql.gtid_slave_pos' doesn't exist
OK
To start mysqld at boot time you have to copy
support-files/mysql.server to the right place for your system
PLEASE REMEMBER TO SET A PASSWORD FOR THE MariaDB root USER !
To do so, start the server, then issue the following commands:
'./bin/mysqladmin' -u root password 'new-password'
'./bin/mysqladmin' -u root -h centos7.localdomain password 'new-password'
Alternatively you can run:
'./bin/mysql_secure_installation'
which will also give you the option of removing the test
databases and anonymous user created by default. This is
strongly recommended for production servers.
See the MariaDB Knowledgebase at http://mariadb.com/kb or the
MySQL manual for more instructions.
You can start the MariaDB daemon with:
cd '.' ; ./bin/mysqld_safe --datadir='/data/mysql'
You can test the MariaDB daemon with mysql-test-run.pl
cd './mysql-test' ; perl mysql-test-run.pl
Please report any problems at http://mariadb.org/jira
The latest information about MariaDB is available at http://mariadb.org/.
You can find additional information about the MySQL part at:
http://dev.mysql.com
Consider joining MariaDB's strong and vibrant community:
https://mariadb.org/get-involved/
[root@centos7 mysql]#ls -l /data/mysql/
total 110660
-rw-rw----. 1 mysql mysql 16384 Mar 4 17:09 aria_log.00000001
-rw-rw----. 1 mysql mysql 52 Mar 4 17:09 aria_log_control
-rw-rw----. 1 mysql mysql 938 Mar 4 17:09 ib_buffer_pool
-rw-rw----. 1 mysql mysql 12582912 Mar 4 17:09 ibdata1
-rw-rw----. 1 mysql mysql 50331648 Mar 4 17:09 ib_logfile0
-rw-rw----. 1 mysql mysql 50331648 Mar 4 17:09 ib_logfile1
drwx------. 2 mysql root 4096 Mar 4 17:09 mysql
-rw-rw----. 1 mysql mysql 29009 Mar 4 17:09 mysql-bin.000001
-rw-rw----. 1 mysql mysql 19 Mar 4 17:09 mysql-bin.index
-rw-rw----. 1 mysql mysql 7 Mar 4 17:09 mysql-bin.state
drwx------. 2 mysql mysql 20 Mar 4 17:09 performance_schema
drwx------. 2 mysql root 6 Mar 4 17:09 test
11、[root@centos7 mysql]#cp support-files/mysql.server /etc/init.d/mysqld
[root@centos7 mysql]#ll /etc/init.d/mysqld
-rwxr-xr-x. 1 root root 12273 Mar 4 17:12 /etc/init.d/mysqld
[root@centos7 mysql]#chkconfig --add mysqld
ch[root@centos7 mysql]#chkconfig --list

Note: This output shows SysV services only and does not include native
systemd services. SysV configuration data might be overridden by native
systemd configuration.

  If you want to list systemd services use 'systemctl list-unit-files'.
  To see services enabled on particular target use
  'systemctl list-dependencies [target]'.

mysqld 0:off 1:off 2:on 3:on 4:on 5:on 6:off 三个文件已正常可使用
netconsole 0:off 1:off 2:off 3:off 4:off 5:off 6:off
network 0:off 1:off 2:on 3:on 4:on 5:on 6:off
[root@centos7 mysql]#service mysqld start
Starting mysqld (via systemctl): [ OK ]
12、[root@centos7 mysql]#echo 'PATH=/usr/local/mysql/bin:$PATH' > /etc/profile.d/mysql.sh
[root@centos7 mysql]#. /etc/profile.d/mysql.sh
[root@centos7 mysql]#mysql
Welcome to the MariaDB monitor. Commands end with ; or \g.
Your MariaDB connection id is 10
Server version: 10.2.15-MariaDB-log MariaDB Server

Copyright (c) 2000, 2018, Oracle, MariaDB Corporation Ab and others.

Type 'help;' or '\h' for help. Type '\c' to clear the current input statement.

MariaDB [(none)]> create database wpdb;
Query OK, 1 row affected (0.01 sec)

MariaDB [(none)]> grant all on wpdb.* to wpuser@'192.168.141.%' identified by '123gxy';
Query OK, 0 rows affected (0.00 sec)

MariaDB [(none)]> quit

13、[root@centos7 data]#unzip wordpress-5.0-zh_CN.zip
[root@centos7 data]#ls
mysql php-7.3.2 wordpress wordpress-5.0-zh_CN.zip
[root@centos7 data]#cp -R wordpress /app/httpd24/htdocs/
[root@centos7 data]#cd wordpress/
[root@centos7 wordpress]#ls
index.php wp-blog-header.php wp-includes wp-settings.php
license.txt wp-comments-post.php wp-links-opml.php wp-signup.php
readme.html wp-config-sample.php wp-load.php wp-trackback.php
wp-activate.php wp-content wp-login.php xmlrpc.php
wp-admin wp-cron.php wp-mail.php
[root@centos7 wordpress]#cp wp-config-sample.php wp-config.php
[root@centos7 wordpress]#vim wp-config.php
// MySQL 设置 - 具体信息来自您正在使用的主机 //
/* WordPress数据库的名称 /
define('DB_NAME', 'wpdb');

/* MySQL数据库用户名 /
define('DB_USER', 'wpuser');

/* MySQL数据库密码 /
define('DB_PASSWORD', '123gxy');

扫描二维码关注公众号,回复: 5417991 查看本文章

/* MySQL主机 /
define('DB_HOST', '192.168.141.150');
14、[root@centos7 ~]#vim /app/httpd24/conf/httpd.conf 把该文件下的2行取消注释,激活
LoadModule proxy_module modules/mod_proxy.so
LoadModule proxy_fcgi_module modules/mod_proxy_fcgi.so
<IfModule dir_module>
DirectoryIndex index.php index.html
</IfModule>
<IfModule ssl_module>
SSLRandomSeed startup builtin
SSLRandomSeed connect builtin
</IfModule>
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 这四行加入
[root@centos7 htdocs]#apachectl restart

15、我们配置php[root@centos7 wordpress]#cd /data/php-7.3.2/
[root@centos7 php-7.3.2]#cp php.ini-production /etc/php.ini
[root@centos7 php-7.3.2]#chmod +x /etc/init.d/php-fpm
[root@centos7 php-7.3.2]#chkconfig --add php-fpm
[root@centos7 php-7.3.2]#chkconfig --list
Note: This output shows SysV services only and does not include native
systemd services. SysV configuration data might be overridden by native
systemd configuration.

  If you want to list systemd services use 'systemctl list-unit-files'.
  To see services enabled on particular target use
  'systemctl list-dependencies [target]'.

mysqld 0:off 1:off 2:on 3:on 4:on 5:on 6:off
netconsole 0:off 1:off 2:off 3:off 4:off 5:off 6:off
network 0:off 1:off 2:on 3:on 4:on 5:on 6:off
php-fpm 0:off 1:off 2:on 3:on 4:on 5:on 6:off
16、[root@centos7 php-7.3.2]#ls /app/php/
bin etc include lib php sbin var 这是编译好的文件
[root@centos7 php-7.3.2]#cd /app/php/etc
[root@centos7 etc]#ls
pear.conf php-fpm.conf.default php-fpm.d
[root@centos7 etc]#cp php-fpm.conf.default php-fpm.conf
[root@centos7 etc]#cp php-fpm.d/www.conf.default php-fpm.d/www.conf
启动服务:[root@centos7 etc]#service php-fpm start
Starting php-fpm done
[root@centos7 etc]#ss -ntl
State Recv-Q Send-Q Local Address:Port Peer Address:Port
LISTEN 0 128 127.0.0.1:9000 :
现在我们去访问页面:
13、[root@centos7 data]#unzip wordpress-5.0-zh_CN.zip
[root@centos7 data]#ls
mysql php-7.3.2 wordpress wordpress-5.0-zh_CN.zip
[root@centos7 data]#cp -R wordpress /app/httpd24/htdocs/
[root@centos7 data]#cd wordpress/
[root@centos7 wordpress]#ls
index.php wp-blog-header.php wp-includes wp-settings.php
license.txt wp-comments-post.php wp-links-opml.php wp-signup.php
readme.html wp-config-sample.php wp-load.php wp-trackback.php
wp-activate.php wp-content wp-login.php xmlrpc.php
wp-admin wp-cron.php wp-mail.php
[root@centos7 wordpress]#cp wp-config-sample.php wp-config.php
[root@centos7 wordpress]#vim wp-config.php
// MySQL 设置 - 具体信息来自您正在使用的主机 //
/* WordPress数据库的名称 /
define('DB_NAME', 'wpdb');

/* MySQL数据库用户名 /
define('DB_USER', 'wpuser');

/* MySQL数据库密码 /
define('DB_PASSWORD', '123gxy');

/* MySQL主机 /
define('DB_HOST', '192.168.141.150');
14、[root@centos7 ~]#vim /app/httpd24/conf/httpd.conf 把该文件下的2行取消注释,激活
LoadModule proxy_module modules/mod_proxy.so
LoadModule proxy_fcgi_module modules/mod_proxy_fcgi.so
<IfModule dir_module>
DirectoryIndex index.php index.html
</IfModule>
<IfModule ssl_module>
SSLRandomSeed startup builtin
SSLRandomSeed connect builtin
</IfModule>
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 这四行加入
[root@centos7 htdocs]#apachectl restart

15、我们配置php[root@centos7 wordpress]#cd /data/php-7.3.2/
[root@centos7 php-7.3.2]#cp php.ini-production /etc/php.ini
[root@centos7 php-7.3.2]#chmod +x /etc/init.d/php-fpm
[root@centos7 php-7.3.2]#chkconfig --add php-fpm
[root@centos7 php-7.3.2]#chkconfig --list
Note: This output shows SysV services only and does not include native
systemd services. SysV configuration data might be overridden by native
systemd configuration.

  If you want to list systemd services use 'systemctl list-unit-files'.
  To see services enabled on particular target use
  'systemctl list-dependencies [target]'.

mysqld 0:off 1:off 2:on 3:on 4:on 5:on 6:off
netconsole 0:off 1:off 2:off 3:off 4:off 5:off 6:off
network 0:off 1:off 2:on 3:on 4:on 5:on 6:off
php-fpm 0:off 1:off 2:on 3:on 4:on 5:on 6:off
16、[root@centos7 php-7.3.2]#ls /app/php/
bin etc include lib php sbin var 这是编译好的文件
[root@centos7 php-7.3.2]#cd /app/php/etc
[root@centos7 etc]#ls
pear.conf php-fpm.conf.default php-fpm.d
[root@centos7 etc]#cp php-fpm.conf.default php-fpm.conf
[root@centos7 etc]#cp php-fpm.d/www.conf.default php-fpm.d/www.conf
启动服务:[root@centos7 etc]#service php-fpm start
Starting php-fpm done
[root@centos7 etc]#ss -ntl
State Recv-Q Send-Q Local Address:Port Peer Address:Port
LISTEN 0 128 127.0.0.1:9000 :
现在我们去访问页面:
编译实现基于FASTCGI的LAMP的wordpress

猜你喜欢

转载自blog.51cto.com/14128387/2357994