系統版本:CentOS 6.9
軟件包
apr-1.6.2.tar.gz
apr-util-1.6.0.tar.gz
httpd-2.4.27.tar.bz2
mariadb-5.5.57-linux-x86_64.tar.gz
php-5.6.31.tar.bz2
wordpress-4.8.1-zh_CN.zip
編譯安裝httpd
準備工作
編譯軟件需要用到開發包組Development tools,在編譯httpd中,會依賴openssl-devel pcre-devel expat-devel三個devel包,提前安裝,避免過程中報錯。
[root@6mini ~]# yum groupinstall "Development tools"
[root@6mini ~]# yum install openssl-devel pcre-devel expat-devel
解壓apr-1.6.2.tar.gz、apr-util-1.6.0.tar.gz和httpd-2.4.27.tar.bz2,復制apr-1.6.2到httpd-2.4.27,并改名為apr,復制apr-util-1.6.0到httpd-2.4.27,并改名為apr-util
[root@6mini ~]# tar xvf apr-1.6.2.tar.gz
[root@6mini ~]# tar xvf apr-util-1.6.0.tar.gz
[root@6mini ~]# tar xvf httpd-2.4.27.tar.bz2
編譯安裝httpd,配置環境變量
[root@6mini httpd-2.4.27]# ./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
[root@6mini httpd-2.4.27]# make -j 2 && make install
[root@6mini httpd-2.4.27]# vim /etc/profile.d/lamp.sh
PASH=/app/httpd24/bin/:$PASH
[root@6mini httpd-2.4.27]# . /etc/profile.d/lamp.sh
[root@6mini httpd-2.4.27]# echo $PASH
/app/httpd24/bin/:
制作httpd啟動程序
復制其他主機上httpd的啟動程序到當前主機并改名為httpd24
[root@MiniLinux ~]#scp /etc/init.d/httpd 192.168.163.105:/etc/init.d/
The authenticity of host '192.168.163.105 (192.168.163.105)' can't be established.
RSA key fingerprint is b5:df:3d:28:80:8e:d4:81:3b:f2:56:81:77:6d:7d:8a.
Are you sure you want to continue connecting (yes/no)? yes
Warning: Permanently added '192.168.163.105' (RSA) to the list of known hosts.
root@192.168.163.105's password:
httpd 100% 3488 3.4KB/s 00:00
[root@6mini httpd-2.4.27]# mv /etc/init.d/httpd /etc/init.d/httpd24
啟動httpd24
修改httpd24的啟動配置文件
[root@6mini httpd-2.4.27]#vim /etc/init.d/httpd24
apachectl=/app/httpd24/bin/apachectl
httpd=${HTTPD-/app/httpd24/bin/httpd}
prog=httpd
pidfile=${PIDFILE-/app/httpd24/logs/httpd.pid}
lockfile=${LOCKFILE-/var/lock/subsys/httpd24}
把httpd24添加到服務列表
[root@6mini httpd-2.4.27]#chkconfig --add httpd24
[root@6mini httpd-2.4.27]#chkconfig --list
auditd 0:off 1:off 2:on 3:on 4:on 5:on 6:off
blk-availability 0:off 1:on 2:on 3:on 4:on 5:on 6:off
crond 0:off 1:off 2:on 3:on 4:on 5:on 6:off
httpd24 0:off 1:off 2:off 3:off 4:off 5:off 6:off
關閉防火墻和selinux
[root@6mini httpd-2.4.27]#iptables -F
[root@6mini httpd-2.4.27]#iptables -L
Chain INPUT (policy ACCEPT)
target prot opt source destination
Chain FORWARD (policy ACCEPT)
target prot opt source destination
Chain OUTPUT (policy ACCEPT)
target prot opt source destination
[root@6mini httpd-2.4.27]#vim /etc/selinux/config
SELINUX=disabled
[root@6mini httpd-2.4.27]#setenforce 0
[root@6mini httpd-2.4.27]#getenforce
Permissive
檢查/app/httpd24/logs/是否生成
[root@6mini httpd-2.4.27]#ll /app/httpd24/logs/
total 8
-rw-r--r--. 1 root root 0 Oct 16 16:37 access_log
-rw-r--r--. 1 root root 246 Oct 16 16:37 error_log
-rw-r--r--. 1 root root 6 Oct 16 16:37 httpd.pid
使用curl檢查httpd是否能正常使用
[root@6mini httpd-2.4.27]#curl 192.168.163.105
<html><body><h1>It works!</h1></body></html>
二進制安裝mariadb
解壓二進制安裝包到/usr/local/目錄,把解壓后的mariadb目錄改名為mysql或者創建一個名為mysql的軟連接
[root@6mini local]#tar xvf mariadb-5.5.57-linux-x86_64.tar.gz -C /usr/local/
[root@6mini ~]#cd /usr/local/
[root@6mini local]#ls
bin etc games include lib lib64 libexec mariadb-5.5.57-linux-x86_64 sbin share src
[root@6mini local]#ln -s mariadb-5.5.57-linux-x86_64/ mysql
[root@6mini local]#ls
bin games lib libexec mysql share
etc include lib64 mariadb-5.5.57-linux-x86_64 sbin src
編輯環境變量的配置文件,在文件中添加mysql環境變量
[root@6mini local]#vim /etc/profile.d/lamp.sh
PASH=/app/httpd24/bin/:/usr/local/mysql/bin/:$PASH
[root@6mini local]#. /etc/profile.d/lamp.sh
[root@6mini local]#echo $PASH
/app/httpd24/bin/:/usr/local/mysql/bin:/app/httpd24/bin/:
創建mysql用戶,指定家目錄為 /app/mysqldb,用戶類型為系統用戶
[root@6mini local]#useradd -r -m -d /app/mysqldb -s /sbin/nologin mysql
[root@6mini local]#getent passwd mysql
mysql:x:498:498::/app/mysqldb:/sbin/nologin
[root@6mini app]#ll -d mysqldb/
drwx------. 2 mysql mysql 4096 Oct 16 17:10 mysqldb/
運行scripts/mysql_install_db腳本,生成mysql文件,指定目錄為/app/mysqldb/,指定用戶為mysql
[root@6mini mysql]#scripts/mysql_install_db --datadir=/app/mysqldb/ --user=mysql
[root@6mini mysqldb]#ll /app/mysqldb/
total 32
-rw-rw----. 1 mysql mysql 16384 Oct 16 17:21 aria_log.00000001
-rw-rw----. 1 mysql mysql 52 Oct 16 17:21 aria_log_control
drwx------. 2 mysql root 4096 Oct 16 17:21 mysql
drwx------. 2 mysql mysql 4096 Oct 16 17:21 performance_schema
drwx------. 2 mysql root 4096 Oct 16 17:21 test
創建mysql配置文件
[root@6mini mysql]#mkdir /etc/mysql
[root@6mini mysql]#cp support-files/my-large.cnf /etc/mysql/my.cnf
[root@6mini mysql]#vim /etc/mysql/my.cnf
[mysqld]
datadir = /app/mysqldb
innodb_file_per_table = ON
skip_name_resolve = ON
復制mysql啟動的服務進程文件到/etc/init.d/,并該名稱mysql添加到服務列表
[root@6mini mysql]#cp support-files/mysql.server /etc/init.d/mysqld
[root@6mini mysql]#chkconfig --add mysqld
創建日志文件,并賦予mysql的寫權限
[root@6mini mysql]#touch /var/log/mysqld.log
[root@6mini mysql]#chown mysql /var/log/mysqld.log
[root@6mini mysql]#ll /var/log/mysqld.log
-rw-r--r--. 1 mysql root 0 Oct 16 17:39 /var/log/mysqld.log
啟動mysql
[root@6mini mysql]#service mysqld start
Starting MySQL.171016 17:41:04 mysqld_safe Logging to '/var/log/mysqld.log'.
171016 17:41:04 mysqld_safe Starting mysqld daemon with databases from /app/mysqldb
.. SUCCESS!
使用mysql_secure_installation初始化數據庫
[root@6mini bin]#mysql_secure_installation
/usr/local/mysql/bin/mysql_secure_installation: line 393: find_mysql_client: command not found
NOTE: RUNNING ALL PARTS OF THIS SCRIPT IS RECOMMENDED FOR ALL MariaDB
SERVERS IN PRODUCTION USE! PLEASE READ EACH STEP CAREFULLY!
In order to log into MariaDB to secure it, we'll need the current
password for the root user. If you've just installed MariaDB, and
you haven't set the root password yet, the password will be blank,
so you should just press enter here.
Enter current password for root (enter for none):
OK, successfully used password, moving on...
Setting the root password ensures that nobody can log into the MariaDB
root user without the proper authorisation.
Set root password? [Y/n] y
New password:
Re-enter new password:
Password updated successfully!
Reloading privilege tables..
... Success!
By default, a MariaDB installation has an anonymous user, allowing anyone
to log into MariaDB without having to have a user account created for
them. This is intended only for testing, and to make the installation
go a bit smoother. You should remove them before moving into a
production environment.
Remove anonymous users? [Y/n] y
... Success!
Normally, root should only be allowed to connect from 'localhost'. This
ensures that someone cannot guess at the root password from the network.
Disallow root login remotely? [Y/n] y
... Success!
By default, MariaDB comes with a database named 'test' that anyone can
access. This is also intended only for testing, and should be removed
before moving into a production environment.
Remove test database and access to it? [Y/n] y
- Dropping test database...
... Success!
- Removing privileges on test database...
... Success!
Reloading the privilege tables will ensure that all changes made so far
will take effect immediately.
Reload privilege tables now? [Y/n] y
... Success!
Cleaning up...
All done! If you've completed all of the above steps, your MariaDB
installation should now be secure.
Thanks for using MariaDB!
使用root登錄數據庫,為workpress創建數據庫,并授權給用戶wpu
[root@6mini bin]#mysql -uroot -p
Enter password:
Welcome to the MariaDB monitor. Commands end with ; or \g.
Your MariaDB connection id is 12
Server version: 5.5.57-MariaDB MariaDB Server
Copyright (c) 2000, 2017, 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.00 sec)
MariaDB [(none)]> GRANT ALL ON wpdb.* TO wpu@'%' IDENTIFIED BY 'centos';
Query OK, 0 rows affected (0.00 sec)
MariaDB [(none)]> QUIT
Bye
使用wpu用戶登錄數據庫,查看并確認數據庫wpdb的生成
[root@6mini bin]#mysql -uwpu -p
Enter password:
Welcome to the MariaDB monitor. Commands end with ; or \g.
Your MariaDB connection id is 13
Server version: 5.5.57-MariaDB MariaDB Server
Copyright (c) 2000, 2017, Oracle, MariaDB Corporation Ab and others.
Type 'help;' or '\h' for help. Type '\c' to clear the current input statement.
MariaDB [(none)]> SHOW DATABASES;
+--------------------+
| Database |
+--------------------+
| information_schema |
| wpdb |
+--------------------+
2 rows in set (0.00 sec)
MariaDB [(none)]>
源碼編譯php
編譯安裝php之前,首先安裝php的依賴包libxml2-devel bzip2-devel libmcrypt-devel,再進行編譯安裝
[root@6mini ~]#yum install libxml2-devel bzip2-devel libmcrypt-devel
[root@6mini ~]#tar xvf php-5.6.31.tar.bz2
[root@6mini ~]#cd php-5.6.31
[root@6mini php-5.6.31]# ./configure --prefix=/app/php --with-mysql=/usr/local/mysql/ --with-openssl --with-mysqli=/usr/local/mysql/bin/mysql_config --enable-mbstring --with-png-dir --with-jpeg-dir --with-freetype-dir --with-zlib --with-libxml-dir=/usr --enable-xml --enable-sockets --with-apxs2=/app/httpd24/bin/apxs --with-mcrypt --with-config-file-path=/etc --with-config-file-scan-dir=/etc/php.d --with-bz2
[root@6mini php-5.6.31]# make -j 2 && make install
復制一個php的配置文件,直接改名,不用設置
[root@6mini php-5.6.31]#cp php.ini-production /etc/php.ini
編輯httpd的配置文件,使httpd支持php
[root@6mini php-5.6.31]#vim /app/httpd24/conf/httpd.conf
<IfModule ssl_module>
SSLRandomSeed startup builtin
SSLRandomSeed connect builtin
</IfModule>
AddType application/x-httpd-php .php
AddType application/x-httpd-php-source .phps
</Directory>
#
# DirectoryIndex: sets the file that Apache will serve if a directory
# is requested.
#
<IfModule dir_module>
DirectoryIndex index.php index.html
測試php程序
首先啟動httpd24,在主目錄里編輯php測試頁進行測試
[root@6mini php-5.6.31]#service httpd24 restart
Stopping httpd: [ OK ]
Starting httpd: AH00557: httpd: apr_sockaddr_info_get() failed for 6mini
AH00558: httpd: Could not reliably determine the server's fully qualified domain name, using 127.0.0.1. Set the 'ServerName' directive globally to suppress this message
[ OK ]
[root@6mini php-5.6.31]#vim /app/httpd24/htdocs/index.php
<?php
phpinfo();
?>
使用瀏覽器查看php網頁
配置wordpress
解壓wordpress到httpd主目錄,并改名為blog
[root@6mini ~]#unzip wordpress-4.8.1-zh_CN.zip -d /app/httpd24/htdocs/
[root@6mini ~]#cd /app/httpd24/htdocs
[root@6mini htdocs]#mv wordpress/ blog
利用wordpress的配置模板生成配置文件,并修改數據庫的信息,確保數據庫正常使用
[root@6mini htdocs]#cd blog/
[root@6mini blog]#mv wp-config-sample.php wp-config.php
[root@6mini blog]#vim wp-config.php
<?php
/**
* WordPress基礎配置文件。
*
* 這個文件被安裝程序用于自動生成wp-config.php配置文件,
* 您可以不使用網站,您需要手動復制這個文件,
* 并重命名為“wp-config.php”,然后填入相關信息。
*
* 本文件包含以下配置選項:
*
* * MySQL設置
* * 密鑰
* * 數據庫表名前綴
* * ABSPATH
*
* @link https://codex.wordpress.org/zh-cn:%E7%BC%96%E8%BE%91_wp-config.php
*
* @package WordPress
*/
// ** MySQL 設置 - 具體信息來自您正在使用的主機 ** //
/** WordPress數據庫的名稱 */
define('DB_NAME', 'wpdb');
/** MySQL數據庫用戶名 */
define('DB_USER', 'wpu');
/** MySQL數據庫密碼 */
define('DB_PASSWORD', 'centos');
/** MySQL主機 */
define('DB_HOST', 'localhost');
瀏覽器登錄并配置wordpress站點
安裝完成