- 1、编译安装搭建wordpress
- 2、搭建php-admin
编译安装搭建wordpress,用fastcgi模式
所需软件包
链接:https://pan.baidu.com/s/1zBqt1KR5_0EdOA0QBaD6yA
提取码:v45k
安装顺序
- apr-1.6.3.tar.gz
- apr-util-1.6.1.tar.gz
- httpd-2.4.33.tar.bz2
- mariadb-10.2.15-linux-x86_64.tar.gz
- php-7.1.18.tar.bz2
- wordpress-4.9.4-zh_CN.tar.gz
第一步.安装需要用到的开发包组
[root@agenitoe yum.repos.d]# yum groupinstall "development tools" -y
[root@agenitoe yum.repos.d]# yum install pcre-devel openssl-devel expat-devel -y
[root@agenitoe ~]# yum install libxml2-devel bzip2-devel libmcrypt-devel libxml2-devel -y 编译PHP需要用到的
第二步.整理源码包,准备解压
[root@agenitoe ~]# mkdir srcs
[root@agenitoe ~]# mv *.gz *.bz2 srcs/
[root@agenitoe ~]# ls
PacVim reset.sh srcs
[root@agenitoe ~]# cd srcs/
[root@agenitoe srcs]# ls
apr-1.6.3.tar.gz httpd-2.4.33.tar.bz2 php-7.1.18.tar.bz2
apr-util-1.6.1.tar.gz mariadb-10.2.15-linux-x86_64.tar.gz
[root@agenitoe srcs]#
第三步.解压源码包,准备编译
[root@agenitoe srcs]# tar xvf apr-1.6.3.tar.gz
[root@agenitoe srcs]# tar xvf apr-util-1.6.1.tar.gz
[root@agenitoe srcs]# tar xvf httpd-2.4.33.tar.bz2
[root@agenitoe srcs]# ls
apr-1.6.3 apr-util-1.6.1 httpd-2.4.33 mariadb-10.2.15-linux-x86_64.tar.gz
apr-1.6.3.tar.gz apr-util-1.6.1.tar.gz httpd-2.4.33.tar.bz2 php-7.1.18.tar.bz2
第四步.移动apr文件夹到httpd,一起编译
[root@agenitoe srcs]# mv apr-1.6.3 httpd-2.4.33/srclib/apr
[root@agenitoe srcs]# mv apr-util-1.6.1 httpd-2.4.33/srclib/apr-util
[root@agenitoe srcs]# cd httpd-2.4.33
[root@agenitoe httpd-2.4.33]# ls
ABOUT_APACHE INSTALL NWGNUmakefile ap.d docs libhttpd.dep support
Apache-apr2.dsw InstallBin.dsp README apache_probes.d emacs-style libhttpd.dsp test
Apache.dsw LAYOUT README.cmake build httpd.dep libhttpd.mak
BuildAll.dsp LICENSE README.platforms buildconf httpd.dsp modules
BuildBin.dsp Makefile.in ROADMAP config.layout httpd.mak os
CHANGES Makefile.win VERSIONING configure httpd.spec server
CMakeLists.txt NOTICE acinclude.m4 configure.in include srclib
第五步.编译安装httpd,注意需要支持pcre
[root@agenitoe httpd-2.4.33]#./configure --prefix=/app/httpd24 --enable-so --enable-ssl --enable-cgi --enable-rewrite --with-zlib --with-pcre --with-included-apr --enable-modules=most --enable-mpms-shared=all --with-mpm=prefork
------- wait-------略过
[root@agenitoe httpd-2.4.33]#make -j 4 && make install 安装
第六步.httpd服务编译好了,需要准备PATH变量
[root@agenitoe httpd-2.4.33]# cd /app/httpd24/
[root@agenitoe httpd24]# ls
bin build cgi-bin conf error htdocs icons include lib logs man manual modules
[root@agenitoe httpd24]#echo PATH=/app/httpd24/bin:$PATH > /etc/profile.d/lamp.sh
[root@agenitoe httpd24]#. /etc/profile.d/lamp.sh
第7步.检查是否能成功允许httpd
[root@agenitoe httpd24]# apachectl
AH00558: httpd: Could not reliably determine the server's fully qualified domain name, using 107.172.236.20. Set the 'ServerName' directive globally to suppress this message
httpd (pid 114) already running
[root@agenitoe httpd24]# ss -ntl
State Recv-Q Send-Q Local Address:Port Peer Address:Port
Cannot open netlink socket: Protocol not supported
LISTEN 0 0 *:22 *:*
LISTEN 0 0 127.0.0.1:25 *:*
LISTEN 0 0 :::80 :::*
LISTEN 0 0 :::22
安装mysql数据库
第一步.解压数据库,软连接必须在/usr/local,而且必须叫mysql
[root@agenitoe app]# cd /root/srcs/
[root@agenitoe srcs]# ls
apr-1.6.3.tar.gz httpd-2.4.33 mariadb-10.2.15-linux-x86_64.tar.gz
apr-util-1.6.1.tar.gz httpd-2.4.33.tar.bz2 php-7.1.18.tar.bz2
[root@agenitoe srcs]# tar xvf mariadb-10.2.15-linux-x86_64.tar.gz -C /usr/local/ 解压到/usr/local
[root@agenitoe srcs]# cd /usr/local
[root@agenitoe local]# ls
bin etc games include lib lib64 libexec mariadb-10.2.15-linux-x86_64 sbin share src
[root@agenitoe local]# ln -s mariadb-10.2.15-linux-x86_64/ mysql 创建一个软连接,这样用软连接的方式比较好维护
[root@agenitoe local]# ll
total 44
drwxr-xr-x 2 root root 4096 Aug 12 2015 bin
drwxr-xr-x 2 root root 4096 Aug 12 2015 etc
drwxr-xr-x 2 root root 4096 Aug 12 2015 games
drwxr-xr-x 2 root root 4096 Aug 12 2015 include
drwxr-xr-x 2 root root 4096 Aug 12 2015 lib
drwxr-xr-x 2 root root 4096 Aug 12 2015 lib64
drwxr-xr-x 2 root root 4096 Aug 12 2015 libexec
drwxr-xr-x 12 root root 4096 May 21 02:51 mariadb-10.2.15-linux-x86_64
lrwxrwxrwx 1 root root 29 May 21 02:52 mysql -> mariadb-10.2.15-linux-x86_64/
drwxr-xr-x 2 root root 4096 Aug 12 2015 sbin
drwxr-xr-x 5 root root 4096 Nov 26 2016 share
drwxr-xr-x 2 root root 4096 Aug 12 2015 src
第二步.创建mysql账号,而且mysql软连接权限也要改变
[root@agenitoe local]# useradd -r -s /sbin/nologin mysql
[root@agenitoe local]# chown -R mysql.mysql mysql/
第三步.建立一个目录,存放数据库
[root@agenitoe local]# mkdir /data/mysql -pv
mkdir: created directory '/data'
mkdir: created directory '/data/mysql'
[root@agenitoe local]# chown mysql.mysql /data/mysql/
[root@agenitoe local]# cd mysql
[root@agenitoe mysql]# ls
COPYING EXCEPTIONS-CLIENT README.md include mysql-test sql-bench
COPYING.thirdparty INSTALL-BINARY bin lib scripts support-files
CREDITS README-wsrep data man share
第四步.添加mysql的path变量
[root@agenitoe mysql]# vim /etc/profile.d/lamp.sh
PATH=/app/httpd24/bin:/usr/local/mysql/bin:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/root/bin
[root@agenitoe mysql]# . /etc/profile.d/lamp.sh
第五步.创建数据库表内容
[root@agenitoe local]# cd mysql
[root@agenitoe mysql]# ls
COPYING EXCEPTIONS-CLIENT README.md include mysql-test sql-bench
COPYING.thirdparty INSTALL-BINARY bin lib scripts support-files
CREDITS README-wsrep data man share
[root@agenitoe mysql]# ./scripts/mysql_install_db --datadir=/data/mysql --user=mysql
Installing MariaDB/MySQL system tables in '/data/mysql' ...
OK
....省略
[root@agenitoe mysql]# ls /data/mysql/ -l
total 110636
-rw-rw---- 1 mysql mysql 16384 May 22 00:13 aria_log.00000001
-rw-rw---- 1 mysql mysql 52 May 22 00:13 aria_log_control
-rw-rw---- 1 mysql mysql 938 May 22 00:13 ib_buffer_pool
-rw-rw---- 1 mysql mysql 50331648 May 22 00:13 ib_logfile0
-rw-rw---- 1 mysql mysql 50331648 May 22 00:13 ib_logfile1
-rw-rw---- 1 mysql mysql 12582912 May 22 00:13 ibdata1
drwx------ 2 mysql root 4096 May 22 00:13 mysql
drwx------ 2 mysql mysql 4096 May 22 00:13 performance_schema
drwx------ 2 mysql root 4096 May 22 00:13 test
第六步.修改mysql配置文件
[root@agenitoe mysql]# cp support-files/my-huge.cnf /etc/my.cnf #复制一个模板
cp: overwrite '/etc/my.cnf'? y
[root@agenitoe mysql]# cp support-files/mysql.server /etc/init.d/mysqld #服务脚本
[root@agenitoe mysql]# vim /etc/my.cnf
[mysqld]
log_bin
datadir=/data/mysql #数据库文件地址
skip-name-resolve #禁止域名解析
max_connections = 5000
default-storage-engine = InnoDB #默认innodb引擎
innodb_file_per_table
port = 3306
socket = /tmp/mysql.sock
skip-external-locking
key_buffer_size = 384M
max_allowed_packet = 1M
table_open_cache = 512
sort_buffer_size = 4M
read_buffer_size = 4M
read_rnd_buffer_size = 16M
myisam_sort_buffer_size = 64M
thread_cache_size = 16
query_cache_size = 64M
第七步.加入开机启动
[root@agenitoe mysql]# chkconfig --add mysqld
[root@agenitoe 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
xinetd based services:
chargen-dgram: off
chargen-stream: off
daytime-dgram: off
daytime-stream: off
discard-dgram: off
discard-stream: off
echo-dgram: off
echo-stream: off
tcpmux-server: off
time-dgram: off
time-stream: off
[root@agenitoe mysql]#
第八步.启动mysql,执行安全脚本
[root@agenitoe mysql]# service mysqld start
Starting mysqld (via systemctl): [ OK ]
[root@agenitoe ~]# mysql_secure_installation
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 #不允许root远程登录
... 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] n #删除test数据库
... skipping.
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!
第九步.创建账号给wordpress使用
[root@agenitoe ~]# mysql -uroot -p
Enter password:
Welcome to the MariaDB monitor. Commands end with ; or \g.
Your MariaDB connection id is 22
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; #创建给wordpress用的数据库
Query OK, 1 row affected (0.00 sec)
MariaDB [(none)]> grant all on wpdb.* to wpuser@'%' identified by '11111111'; #创建数据库用户
Query OK, 0 rows affected (0.01 sec)
MariaDB [(none)]> flush privileges; #刷新权限
Query OK, 0 rows affected (0.00 sec)
数据库就到此为止结束
编译安装PHP,基于fastcgi模式
第一步.解压PHP
[root@agenitoe srcs]# tar xvf php-7.1.18.tar.bz2
第二步.编译PHP,并且安装
[root@agenitoe 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
[root@agenitoe php-7.1.18]# make -j 4 && make install
第三步.PHP安装后整个PATH变量还需要修改
[root@agenitoe ~]# vim /etc/profile.d/lamp.sh
PATH=/app/php/bin:/app/php/sbin:/app/httpd24/bin:/usr/local/mysql/bin:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/root/bin
[root@agenitoe ~]# . /etc/profile.d/lamp.sh
第四步.准备PHP配置文件
[root@agenitoe php-7.1.18]# cp php.ini-production /etc/php.ini
[root@agenitoe php-7.1.18]# vim /etc/php.ini
; http://php.net/post-max-size
post_max_size = 3000M #这一行是上传的数据大小(不仅仅是文件)可以根据自己需求修改
; http://php.net/upload-max-filesize
upload_max_filesize = 300M #上传文件大小
第五步.还需要准备启动脚本
[root@agenitoe php-7.1.18]# cp sapi/fpm/init.d.php-fpm /etc/init.d/php-fpm
cp: overwrite '/etc/init.d/php-fpm'? y
[root@agenitoe php-7.1.18]# chmod +x /etc/init.d/php-fpm #加上执行权限
第六步.让PHP变成服务
[root@agenitoe php-7.1.18]# chkconfig --add php-fpm
第七步.配置文件复制好了,就可以启动服务了
[root@agenitoe php-7.1.18]# cd /app/php/
[root@agenitoe php]# ls
bin etc include lib php sbin var
[root@agenitoe php]# cd etc
[root@agenitoe etc]# ls
pear.conf php-fpm.conf.default php-fpm.d
[root@agenitoe etc]# cp php-fpm.conf.default php-fpm.conf
[root@agenitoe etc]# cd php-fpm.d
[root@agenitoe php-fpm.d]# ls
www.conf.default
[root@agenitoe php-fpm.d]# cp www.conf.default www.conf
[root@agenitoe php-fpm.d]# service php-fpm start
Starting php-fpm done
[root@agenitoe php-fpm.d]# ss -ntl
State Recv-Q Send-Q Local Address:Port Peer Address:Port
Cannot open netlink socket: Protocol not supported
LISTEN 0 0 *:22 *:*
LISTEN 0 0 127.0.0.1:25 *:*
LISTEN 0 0 127.0.0.1:9000 *:* #9000端口打开说明启动成功
LISTEN 0 0 :::80 :::*
LISTEN 0 0 :::22 :::*
LISTEN 0 0 :::3306 :::*
注意:但是由于我之前并没有创建apache账号,所以现在httpd服务和php服务用的是默认用户,想要用apache账号执行进程,还需要修改配置,在这里我就不做了
如果创建了apache就需要把这两行改成apache
第八步.配置httpd支持php
[root@agenitoe php-fpm.d]# vim /app/httpd24/conf/httpd.conf
LoadModule proxy_module modules/mod_proxy.so #取消这两行的注释
LoadModule proxy_fcgi_module modules/mod_proxy_fcgi.so
**主页也需要在配置文件里修改下,有先找PHP文件**
#
<IfModule dir_module>
DirectoryIndex index.php index.html #index.php写在前面
</IfModule>
**在最后加4行**
AddType application/x-httpd-php .php
AddType application/x-httpd-source .phps
ProxyREquests OFF
proxyPassmatch ^/(.*\.php)$ fcgi://127.0.0.1:9000/app/httpd24/htdocs/$1
第九步.重启httpd服务
[root@agenitoe php-fpm.d]# apachectl stop
AH00526: Syntax error on line 512 of /app/httpd24/conf/httpd.conf:
AddType requires at least two arguments, a mime type followed by one or more file extensions
[root@agenitoe php-fpm.d]# apachectl
AH00526: Syntax error on line 512 of /app/httpd24/conf/httpd.conf:
AddType requires at least two arguments, a mime type followed by one or more file extensions
[root@agenitoe php-fpm.d]# ss -ntl
State Recv-Q Send-Q Local Address:Port Peer Address:Port
Cannot open netlink socket: Protocol not supported
LISTEN 0 0 *:22 *:*
LISTEN 0 0 127.0.0.1:25 *:*
LISTEN 0 0 127.0.0.1:9000 *:*
LISTEN 0 0 :::80 :::*
LISTEN 0 0 :::22 :::*
LISTEN 0 0 :::3306 :::*
配置wordpress
第一步.解压wordpress
[root@agenitoe ~]# ls /root/srcs/ -l
total 461844
-rw-r--r-- 1 root root 1072661 May 3 11:03 apr-1.6.3.tar.gz
-rw-r--r-- 1 root root 554301 May 3 11:03 apr-util-1.6.1.tar.gz
drwxr-sr-x 12 root 40 4096 May 21 02:36 httpd-2.4.33
-rw-r--r-- 1 root root 6934765 May 3 11:05 httpd-2.4.33.tar.bz2
-rw-r--r-- 1 root root 440117420 Apr 22 23:26 mariadb-10.2.15-linux-x86_64.tar.gz
drwxr-xr-x 18 1000 1000 4096 May 22 01:34 php-7.1.18
-rw-r--r-- 1 root root 15140158 May 6 22:09 php-7.1.18.tar.bz2
-rw-r--r-- 1 root root 9082696 May 5 03:07 wordpress-4.9.4-zh_CN.tar.gz
[root@agenitoe htdocs]# cd /app/httpd24/htdocs/
[root@agenitoe htdocs]# tar xvf /root/srcs/wordpress-4.9.4-zh_CN.tar.gz -C .
第二步.把wordpress文件夹做整个目录为网页
[root@agenitoe htdocs]# ls
index.html wordpress
[root@agenitoe htdocs]# mv wordpress/* .
第三步.修wordpress改配置文件
[root@agenitoe htdocs]# ls
index.html wordpress wp-comments-post.php wp-includes wp-mail.php xmlrpc.php
index.php wp-activate.php wp-config-sample.php wp-links-opml.php wp-settings.php
license.txt wp-admin wp-content wp-load.php wp-signup.php
readme.html wp-blog-header.php wp-cron.php wp-login.php wp-trackback.php
[root@agenitoe htdocs]# rm -rf wordpress/
[root@agenitoe htdocs]# rm -f index.html
[root@agenitoe htdocs]# cp wp-config-sample.php wp-config.php #复制样板配置文件,作为配置文件
[root@agenitoe htdocs]# vim wp-config.php
// ** MySQL 设置 - 信正使D主 ** //
/** WordPressDM称 */
define('DB_NAME', 'wpdb');
/** MySQLM */
define('DB_USER', 'wpuser');
/** MySQLA */
define('DB_PASSWORD', '1111111');
/** MySQL主 */
define('DB_HOST', 'localhost');
/** [建表认DGA */
define('DB_CHARSET', 'utf8');
/** F类KB确请 */
define('DB_COLLATE', '');
成功
搭建php-admin
如果你的php是用yum源下载的,那么你要去官网查找适合你的版本
[root@agenitoe ~]# yum info php
Loaded plugins: fastestmirror
Loading mirror speeds from cached hostfile
Available Packages
Name : php
Arch : x86_64
Version : 5.4.16
Release : 46.el7
Size : 1.4 M
Repo : base1
Summary : PHP scripting language for creating dynamic web sites
URL : http://www.php.net/
License : PHP and Zend and BSD
Description : PHP is an HTML-embedded scripting language. PHP attempts to make it
: easy for developers to write dynamically generated web pages. PHP also
: offers built-in database integration for several commercial and
: non-commercial database management systems, so writing a
: database-enabled webpage with PHP is fairly simple. The most common
: use of PHP coding is probably as a replacement for CGI scripts.
:
: The php package contains the module (often referred to as mod_php)
: which adds support for the PHP language to Apache HTTP Server.
由于我们之前编译安装的是较新的PHP版本,所以去官网下载通用版本即可
第一步.解压源码文件,这个源码应该挡在网站的目录下
[root@agenitoe ~]# unzip phpMyAdmin-4.8.5-all-languages.zip
[root@agenitoe ~]#mv phpMyAdmin-4.8.5-all-languages /app/httpd24/htdocs/pma
[root@agenitoe ~]# cd /app/httpd24/htdocs/pma
[root@agenitoe pma]# ls
CODE_OF_CONDUCT.md db_structure.php schema_export.php tbl_get_field.php
CONTRIBUTING.md db_tracking.php server_binlog.php tbl_gis_visualization.php
ChangeLog db_triggers.php server_collations.php tbl_import.php
DCO doc server_databases.php tbl_indexes.php
LICENSE error_report.php server_engines.php tbl_operations.php
README examples server_export.php tbl_recent_favorite.php
RELEASE-DATE-4.8.5 export.php server_import.php tbl_relation.php
ajax.php favicon.ico server_plugins.php tbl_replace.php
browse_foreigners.php gis_data_editor.php server_privileges.php tbl_row_action.php
第二步.复制样板配置文件作为配置文件
[root@agenitoe pma]# cp config.sample.inc.php config.inc.php
[root@agenitoe pma]# vim config.inc.php
/**
* This is needed for cookie based authentication to encrypt password in
* cookie. Needs to be 32 chars long.
*/
$cfg['blowfish_secret'] = 'slksjsj'; /* YOU MUST FILL IN THIS FOR COOKIE AUTH! */ ## 随便写一个字符串,当cookie验证
/**
第三步.测试成功
如果报错,那就是缺少工具包mbstring
[root@agenitoe ~]# yum install -y php-mbstring
[root@agenitoe ~]# systemctl restart httpd ##重启生效