一、服务器环境搭建
在使用源码包安装服务程序之前,首先要让安装主机具备编译程序源码的环境。这需要具备C语言、C++语言、Perl语言的编译器,以及各种常见的编译支持函数库程序。因此请先配置妥当软件仓库,然后把下面列出的这些软件包都统统安装上:
[root@TradeProbe ~]# mkdir -p /media/cdrom
# 挂载光盘并设置为开机自动挂载
[root@TradeProbe ~]# mount /dev/cdrom /media/cdrom/
[root@TradeProbe ~]# echo "/dev/cdrom /media/cdrom iso9660 defaults 0 0" >> /etc/fstab
[root@TradeProbe ~]# cd /etc/yum.repos.d/
# 编辑YUM仓库的配置文件
[root@TradeProbe yum.repos.d]# vi rhel7.repo
[rhel7]
name=rhel7
baseurl=file:///media/cdrom
gpgcheck=0
enabled=1
[root@TradeProbe yum.repos.d]# yum -y install apr* autoconf automake numactl bison bzip2-devel cpp curl-devel fontconfig-devel freetype-devel gcc gcc-c++ gd-devel gettext-devel kernel-headers keyutils-libs-devel krb5-devel libcom_err-devel libpng-devel libjpeg* libsepol-devel libselinux-devel libstdc++-devel libtool* libxml2-devel libXpm* libxml* libXaw-devel libXmu-devel libtiff* make openssl-devel patch pcre-devel perl php-common php-gd telnet zlib-devel libtirpc-devel gtk* ntpstat na* bison* lrzsz cmake ncurses-devel libzip-devel libxslt-devel gdbm-devel readline-devel gmp-devel
[root@TradeProbe ~]# cd /tmp/lnmp/
[root@TradeProbe lnmp]# ls
cmake-2.8.11.2.tar.gz jpegsrc.v9a.tar.gz libpng-1.6.12.tar.gz nginx-1.6.0.tar.gz php-5.5.14.tar.gz yasm-1.2.0.tar.gz
Discuz_x3.2_SC_GBK.zip libgd-2.1.0.tar.gz libvpx-v1.3.0.tar.bz2 openssl-1.0.1h.tar.gz t1lib-5.1.2.tar.gz zlib-1.2.8.tar.gz
freetype-2.5.3.tar.gz libmcrypt-2.5.8.tar.gz mysql-5.6.19.tar.gz pcre-8.35.tar.gz tiff-4.0.3.tar.gz
[root@TradeProbe lnmp]#
# 解压源码包程序
[root@TradeProbe lnmp]# tar xjvf libvpx-v1.3.0.tar.bz2 -C /usr/local/lnmp/
# 查看所有解压的源码包程序
[root@TradeProbe lnmp]# ls
cmake-2.8.11.2 jpeg-9a libmcrypt-2.5.8 libvpx-v1.3.0 nginx-1.6.0 pcre-8.35 t1lib-5.1.2 yasm-1.2.0
freetype-2.5.3 libgd-2.1.0 libpng-1.6.12 mysql-5.6.19 openssl-1.0.1h php-5.5.14 tiff-4.0.3 zlib-1.2.8
[root@TradeProbe lnmp]#
# 下载及解压源码包文件
[root@TradeProbe lnmp]# tar xzvf cmake-2.8.11.2.tar.gz -C /usr/local/lnmp
[root@TradeProbe lnmp]# cd cmake-2.8.11.2/
# 编译源码包代码
[root@TradeProbe cmake-2.8.11.2]# ./configure
# 生成二进制安装程序
[root@TradeProbe lnmp]# make
# 运行二进制的服务程序安装包
[root@TradeProbe lnmp]# make install
二、配置MySQL服务
[root@TradeProbe lnmp]# useradd -s /sbin/nologin mysql
[root@TradeProbe lnmp]# mkdir -p /usr/local/mysql/var
[root@TradeProbe lnmp]# chown -Rf mysql:mysql /usr/local/mysql
[root@TradeProbe mysql-5.6.19]# cd mysql-5.6.19/
# 编译数据库
# 其中,-DCMAKE_INSTALL_PREFIX参数用于定义数据库服务程序的保存目录,-DMYSQL_DATADIR参数用于定义真实数据库文件的目录,-DSYSCONFDIR则是定义MySQL数据库配置文件的保存目录
[root@TradeProbe mysql-5.6.19]# cmake . -DCMAKE_INSTALL_PREFIX=/usr/local/mysql -DMYSQL_DATADIR=/usr/local/mysql/var -DSYSCONFDIR=/etc
# 生成二进制数据库文件
[root@TradeProbe mysql-5.6.19]# make
# 安装MySQL数据库服务
[root@TradeProbe mysql-5.6.19]# make install
编译、生成和安装数据库文件时间较长,需要耐心等到。
4. 为了让MySQL数据库程序正常运行,需要先删除/etc目录中的默认配置文件my.cnf
[root@TradeProbe lnmp]# rm -rf /etc/my.cnf
5.在MySQL数据库程序的保存目录scripts内运行一个名为mysql_install_db的脚本程序
[root@TradeProbe lnmp]# cd /usr/local/mysql/scripts/
[root@TradeProbe scripts]# ls
mysql_install_db
# 运行这个脚本程序,并使用--user参数指定MySQL服务的对应账号名称mysql,使用--basedir参数指定MySQL服务程序的保存目录,使用--datadir参数指定MySQL真实数据库的文件保存目录。
[root@TradeProbe scripts]# ./mysql_install_db --user=mysql --basedir=/usr/local/mysql --datadir=/usr/local/mysql/var
这样即可以生成系统数据库文件,也会生成出新的MySQL服务配置文件。
6. 把系统新生成的mysql数据库配置文件链接到/etc目录中。
[root@TradeProbe mysql]# ln -s my.cnf /etc/my.cnf
7.把程序目录中的开机程序文件复制到/etc/rc.d/init.d目录中,以便通过service命令来管理MySQL数据库服务程序。修改数据库脚本文件的权限修改成755以便于让用户有执行该脚本的权限。
[root@TradeProbe mysql]# cp ./support-files/mysql.server /etc/rc.d/init.d/mysqld
[root@TradeProbe mysql]# chmod 755 /etc/rc.d/init.d/mysqld
8.编辑刚刚复制的MySQL数据库脚本文件,把basedir与datadir参数分别修改为MySQL数据库程序的保存目录和真实数据库的文件内容。
[root@TradeProbe mysql]# vi /etc/rc.d/init.d/mysqld
--------------省略部分输出------------
42
43 # If you change base dir, you must also change datadir. These may get
44 # overwritten by settings in the MySQL configuration files.
45
**46 basedir=/usr/local/mysql**
**47 datadir=/usr/local/mysql/var**
48
49 # Default value, in seconds, afterwhich the script should timeout waiting
50 # for server start.
--------------省略部分输出------------
9.编辑MySQL数据库服务的环境变量,并使用source命令立即生效
[root@TradeProbe mysql]# vi /etc/profile
--------------省略部分输出------------
65 for i in /etc/profile.d/*.sh /etc/profile.d/sh.local ; do
66 if [ -r "$i" ]; then
67 if [ "${-#*i}" != "$-" ]; then
68 . "$i"
69 else
70 . "$i" >/dev/null
71 fi
72 fi
73 done
74 **export PATH=$PATH:/usr/local/mysql/bin**
75 unset i
76 unset -f pathmunge
[root@TradeProbe mysql]# source /etc/profile
[root@TradeProbe mysql]# service mysqld start
Starting MySQL. SUCCESS!
[root@TradeProbe mysql]# chkconfig mysqld on
[root@TradeProbe mysql]#
[root@TradeProbe mysql]# mkdir /var/lib/mysql
[root@TradeProbe mysql]# ln -s /usr/local/mysql/lib/mysql /usr/lib/mysql
[root@TradeProbe mysql]# ln -s /tmp/mysql.sock /var/lib/mysql/mysql.sock
[root@TradeProbe mysql]# ln -s /usr/local/mysql/include/mysql /usr/include/mysql
[root@TradeProbe mysql]#
[root@TradeProbe mysql]# mysql_secure_installation
NOTE: RUNNING ALL PARTS OF THIS SCRIPT IS RECOMMENDED FOR ALL MySQL
SERVERS IN PRODUCTION USE! PLEASE READ EACH STEP CAREFULLY!
In order to log into MySQL to secure it, we'll need the current
password for the root user. If you've just installed MySQL, 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 MySQL
root user without the proper authorisation.
Set root password? [Y/n] y **(要为root管理员设置数据库的密码)**
New password: **输入root管理员设置的数据库密码**
Re-enter new password: **再输入一次密码**
Password updated successfully!
Reloading privilege tables..
... Success!
By default, a MySQL installation has an anonymous user, allowing anyone
to log into MySQL 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, MySQL 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 **(删除test数据库并取消对其的访问权限)**
- 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!
All done! If you've completed all of the above steps, your MySQL
installation should now be secure.
Thanks for using MySQL!
Cleaning up...
[root@TradeProbe mysql]#
三、配置Nginx服务
在正式安装Nginx服务程序之前,我们还需要为其解决相关的软件依赖性问题。安装perl语言兼容的正则表达式库的软件包pcre。
[root@TradeProbe lnmp]# cd pcre-8.35/
# 编译、生成二进制文件、安装在一条命令中使用
[root@TradeProbe pcre-8.35]# ./configure --prefix=/usr/local/pcre ; make ; make install
[root@TradeProbe lnmp]# cd openssl-1.0.1h
[root@TradeProbe openssl-1.0.1h]# ./config --prefix=/usr/local/openssl ; make ; make install
# 编辑openssl环境变量,将这个目录添加到PATH环境变量中,并写入到配置文件中。
[root@TradeProbe openssl-1.0.1h]# vi /etc/profile
--------------省略部分输出------------
65 for i in /etc/profile.d/*.sh /etc/profile.d/sh.local ; do
66 if [ -r "$i" ]; then
67 if [ "${-#*i}" != "$-" ]; then
68 . "$i"
69 else
70 . "$i" >/dev/null
71 fi
72 fi
73 done
74 **export PATH=$PATH:/usr/local/mysql/bin:/usr/local/openssl/bin**
75 unset i
76 unset -f pathmunge
# 执行source命令让PATH环境变量立即生效。
[root@TradeProbe openssl-1.0.1h]# source /etc/profile
[root@TradeProbe lnmp]# cd zlib-1.2.8/
[root@TradeProbe zlib-1.2.8]# ./configure --prefix=/usr/local/zlib ; make ; make intall
至此,Nginx具有依赖关系的软件包都已经安装好了。现在需要创建一个用于执行Nginx服务程序的账户。
4. 创建用于执行Nginx服务的账户nginxadmin
[root@TradeProbe zlib-1.2.8]# useradd -s /sbin/nologin nginxadmin
[root@TradeProbe zlib-1.2.8]# cd ..
[root@TradeProbe zlib-1.2.8]# cd nginx-1.6.0
[root@TradeProbe nginx-1.6.0]# ./configure --prefix=/usr/local/nginx --without-http_memcached_module --user=nginxadmin --group=nginxadmin --with-http_stub_status_module --with-http_ssl_module --with-http_gzip_static_module --with-openssl=/usr/local/lnmp/openssl-1.0.1h --with-zlib=/usr/local/lnmp/zlib-1.2.8 --with-pcre=/usr/local/lnmp/pcre-8.35 ; make ; make install
[root@TradeProbe conf]# vi /etc/rc.d/init.d/nginx
#!/bin/bash
# nginx - this script starts and stops the nginx daemon
# chkconfig: - 85 15
# description: Nginx is an HTTP(S) server, HTTP(S) reverse \
# proxy and IMAP/POP3 proxy server
# processname: nginx
# config: /etc/nginx/nginx.conf
# config: /usr/local/nginx/conf/nginx.conf
# pidfile: /usr/local/nginx/logs/nginx.pid
# Source function library.
. /etc/rc.d/init.d/functions
# Source networking configuration.
. /etc/sysconfig/network
# Check that networking is up.
[ "$NETWORKING" = "no" ] && exit 0
nginx="/usr/local/nginx/sbin/nginx"
prog=$(basename $nginx)
NGINX_CONF_FILE="/usr/local/nginx/conf/nginx.conf"
[ -f /etc/sysconfig/nginx ] && . /etc/sysconfig/nginx
lockfile=/var/lock/subsys/nginx
make_dirs() {
# make required directories
user=`$nginx -V 2>&1 | grep "configure arguments:" | sed 's/[^*]*--user=\([^ ]*\).*/\1/g' -`
if [ -z "`grep $user /etc/passwd`" ]; then
useradd -M -s /bin/nologin $user
fi
options=`$nginx -V 2>&1 | grep 'configure arguments:'`
for opt in $options; do
if [ `echo $opt | grep '.*-temp-path'` ]; then
value=`echo $opt | cut -d "=" -f 2`
if [ ! -d "$value" ]; then
# echo "creating" $value
mkdir -p $value && chown -R $user $value
fi
fi
done
}
start() {
[ -x $nginx ] || exit 5
[ -f $NGINX_CONF_FILE ] || exit 6
make_dirs
echo -n $"Starting $prog: "
daemon $nginx -c $NGINX_CONF_FILE
retval=$?
echo
[ $retval -eq 0 ] && touch $lockfile
return $retval
}
stop() {
echo -n $"Stopping $prog: "
killproc $prog -QUIT
retval=$?
echo
[ $retval -eq 0 ] && rm -f $lockfile
return $retval
}
restart() {
#configtest || return $?
stop
sleep 1
start
}
reload() {
#configtest || return $?
echo -n $"Reloading $prog: "
killproc $nginx -HUP
RETVAL=$?
echo
}
force_reload() {
restart
}
configtest() {
$nginx -t -c $NGINX_CONF_FILE
}
rh_status() {
status $prog
}
rh_status_q() {
rh_status >/dev/null 2>&1
}
case "$1" in
start)
rh_status_q && exit 0
$1
;;
stop)
rh_status_q || exit 0
$1
;;
restart|configtest)
$1
;;
reload)
rh_status_q || exit 7
$1
;;
force-reload)
force_reload
;;
status)
rh_status
;;
condrestart|try-restart)
rh_status_q || exit 0
;;
*)
echo $"Usage: $0 {start|stop|status|restart|condrestart|try-restart|reload|force-reload|configtest}"
exit 2
esac
# nginx脚本文件赋予755权限
[root@TradeProbe conf]# chmod 755 /etc/rc.d/init.d/nginx
# 重启nginx服务
[root@TradeProbe conf]# /etc/rc.d/init.d/nginx restart
Reloading systemd: [ 确定 ]
Restarting nginx (via systemctl): [ 确定 ]
# 设置开机自动启动nginx服务
[root@TradeProbe conf]# chkconfig nginx on
[root@TradeProbe conf]#
四、配置PHP服务
使用源码包的方式编译安装PHP语言环境其实并不复杂,难点在于解决PHP的程序包和其他软件的依赖关系。为此需要先安装部署将近十个用于搭建网站页面的软件程序包,然后才能正式安装PHP程序。
[root@TradeProbe lnmp]# cd yasm-1.2.0/
[root@TradeProbe yasm-1.2.0]# ./configure ; make ; make install
[root@TradeProbe lnmp]# cd libvpx-v1.3.0/
[root@TradeProbe libvpx-v1.3.0]# ./configure --prefix=/usr/local/libvpx --enable-shared --enable-vp9 ; make ; make install
[root@TradeProbe lnmp]# cd tiff-4.0.3/
[root@TradeProbe tiff-4.0.3]# ./configure --prefix=/usr/local/tiff --enable-shared ; make ; make install
[root@TradeProbe lnmp]# cd libpng-1.6.12/
[root@TradeProbe libpng-1.6.12]# ./configure --prefix=/usr/local/libpng --enable-shared ; make ; make install
[root@TradeProbe lnmp]# cd freetype-2.5.3/
[root@TradeProbe freetype-2.5.3]# ./configure --prefix=/usr/local/freetype --enable-shared ; make ; make install
[root@TradeProbe lnmp]# cd jpeg-9a/
[root@TradeProbe jpeg-9a]# ./configure --prefix=/usr/local/jpeg --enable-shared ; make ; make install
[root@TradeProbe lnmp]# cd libgd-2.1.0/
[root@TradeProbe libgd-2.1.0]# ./configure --prefix=/usr/local/libgd --enable-shared --with-jpeg=/usr/local/jpeg --with-png=/usr/local/libpng --with-freetype=/usr/local/freetype --with-fontconfig=/usr/local/freetype --with-xpm=/usr/ --with-tiff=/usr/local/tiff --with-vpx=/usr/local/libvpx ; make ; make install
[root@TradeProbe lnmp]# cd t1lib-5.1.2/
[root@TradeProbe t1lib-5.1.2]# ./configure --prefix=/usr/local/t1lib --enable-shared ; make ; make install
# 链接函数文件
[root@TradeProbe t1lib-5.1.2]# ln -s /usr/lib64/libltdl.so /usr/lib/libltdl.so
[root@TradeProbe t1lib-5.1.2]# cp -frp /usr/lib64/libXpm.so* /usr/lib/
[root@TradeProbe lnmp]# cd php-5.5.14/
[root@TradeProbe php-5.5.14]# export LD_LIBRARY_PATH=/usr/local/libgd/lib
[root@TradeProbe php-5.5.14]# ./configure --prefix=/usr/local/php --with-config-file-path=/usr/local/php/etc --with-mysql=/usr/local/mysql --with-mysqli=/usr/local/mysql/bin/mysql_config --with-mysql-sock=/tmp/mysql.sock --with-pdo-mysql=/usr/local/mysql --with-gd --with-png-dir=/usr/local/libpng --with-jpeg-dir=/usr/local/jpeg --with-freetype-dir=/usr/local/freetype --with-xpm-dir=/usr/ --with-vpx-dir=/usr/local/libvpx/ --with-zlib-dir=/usr/local/zlib --with-t1lib=/usr/local/t1lib --with-iconv --enable-libxml --enable-xml --enable-bcmath --enable-shmop --enable-sysvsem --enable-inline-optimization --enable-opcache --enable-mbregex --enable-fpm --enable-mbstring --enable-ftp --enable-gd-native-ttf --with-openssl --enable-pcntl --enable-sockets --with-xmlrpc --enable-zip --enable-soap --without-pear --with-gettext --enable-session --with-mcrypt --with-curl --enable-ctype ; make ; make install
注意:在首次编译PHP软件时报错:“PHP configure: error: mcrypt.h not found. Please reinstall libmcrypt. ”,经查是libmcrypt版本问题造成,重新安装libmcrypt-2.5.7的源码包后,再次编译、生成、安装没有报错信息。成功安装PHP。
10. 在php源码包程序安装完成后,需要删除当前默认的配置文件,然后将php服务程序目录中相应的配置文件复制过来:
[root@TradeProbe php-5.5.14]# rm -rf /etc/php.ini
[root@TradeProbe php-5.5.14]# ln -s /usr/local/php/etc/php.ini /etc/php.ini
[root@TradeProbe php-5.5.14]# cp php.ini-production /usr/local/php/etc/php.ini
[root@TradeProbe php-5.5.14]# cp /usr/local/php/etc/php-fpm.conf.default /usr/local/php/etc/php-fpm.conf
[root@TradeProbe php-5.5.14]# ln -s /usr/local/php/etc/php-fpm.conf /etc/php-fpm.conf
[root@TradeProbe php-5.5.14]#
[root@TradeProbe ~]# vim /usr/local/php/etc/php-fpm.conf
1 ;;;;;;;;;;;;;;;;;;;;;
2 ; FPM Configuration ;
3 ;;;;;;;;;;;;;;;;;;;;;
4
5 ; All relative paths in this configuration file are relative to PHP's install
6 ; prefix (/usr/local/php). This prefix can be dynamically changed by using the
7 ; '-p' argument from the command line.
8
9 ; Include one or more files. If glob(3) exists, it is used to include a bunch of
10 ; files from a glob(3) pattern. This directive can be used everywhere in the
11 ; file.
12 ; Relative path can also be used. They will be prefixed by:
13 ; - the global prefix if it's been set (-p argument)
14 ; - /usr/local/php otherwise
15 ;include=etc/fpm.d/*.conf
16
17 ;;;;;;;;;;;;;;;;;;
18 ; Global Options ;
19 ;;;;;;;;;;;;;;;;;;
20
21 [global]
22 ; Pid file
23 ; Note: the default prefix is /usr/local/php/var
24 ; Default Value: none
25 **pid = run/php-fpm.pid**
26
27 ; Error log file
28 ; If it's set to "syslog", log is sent to syslogd instead of being written'
--------------省略部分输出------------
145 ; Unix user/group of processes
146 ; Note: The user is mandatory. If the group is not set, the default user's group
147 ; will be used.
148 **user = nginxadmin**
149 **group = nginxadmin**
150
--------------省略部分输出-----------
[root@TradeProbe php-5.5.14]# cp sapi/fpm/init.d.php-fpm /etc/rc.d/init.d/php-fpm
[root@TradeProbe php-5.5.14]# chmod 755 /etc/rc.d/init.d/php-fpm
[root@TradeProbe php-5.5.14]# chkconfig php-fpm on
[root@TradeProbe php-5.5.14]# vim /usr/local/php/etc/php.ini
………………省略部分输出信息………………
300
301 ; This directive allows you to disable certain functions for security reasons.
302 ; It receives a comma-delimited list of function names. This directive is
303 ; *NOT* affected by whether Safe Mode is turned On or Off.
304 ; http://php.net/disable-functions
305 disable_functions = passthru,exec,system,chroot,scandir,chgrp,chown,shell_exec,proc_open,proc_get_status,ini_alter,ini_alter,ini_restor e,dl,openlog,syslog,readlink,symlink,popepassthru,stream_socket_server,escapeshellcmd,dll,popen,disk_free_space,checkdnsrr,checkdnsrr,g etservbyname,getservbyport,disk_total_space,posix_ctermid,posix_get_last_error,posix_getcwd,posix_getegid,posix_geteuid,posix_getgid,po six_getgrgid,posix_getgrnam,posix_getgroups,posix_getlogin,posix_getpgid,posix_getpgrp,posix_getpid,posix_getppid,posix_getpwnam,posix_ getpwuid,posix_getrlimit,posix_getsid,posix_getuid,posix_isatty,posix_kill,posix_mkfifo,posix_setegid,posix_seteuid,posix_setgid,posix_ setpgid,posix_setsid,posix_setuid,posix_strerror,posix_times,posix_ttyname,posix_uname
306
14.最后,还需要编辑Nginx服务程序的主配置文件,把第2行的井号(#)删除,然后在后面写上负责运行Nginx服务程序的账户名称和用户组名称;在第45行的index参数后面写上网站的首页名称。最后是将第65~71行参数前的井号(#)删除来启用参数,主要是修改第69行的脚本名称路径参数,其中$document_root变量即为网站信息存储的根目录路径,若没有设置该变量,则Nginx服务程序无法找到网站信息,因此会提示“404页面未找到”的报错信息。在确认参数信息填写正确后便可重启Nginx服务与php-fpm服务。
[root@TradeProbe php-5.5.14]# vim /usr/local/nginx/conf/nginx.conf
1
2 user www www;
3 worker_processes 1;
4
5 #error_log logs/error.log;
6 #error_log logs/error.log notice;
7 #error_log logs/error.log info;
8
9 #pid logs/nginx.pid;
10
11
………………省略部分输出信息………………
40
41 #access_log logs/host.access.log main;
42
43 location / {
44 root html;
45 index index.html index.htm index.php;
46 }
47
………………省略部分输出信息………………
62
63 #pass the PHP scripts to FastCGI server listening on 127.0.0.1:9000
64
65 location ~ \.php$ {
66 root html;
67 fastcgi_pass 127.0.0.1:9000;
68 fastcgi_index index.php;
69 fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
70 include fastcgi_params;
71 }
72
………………省略部分输出信息………………
[root@TradeProbe php-5.5.14]# systemctl restart nginx.service
[root@TradeProbe php-5.5.14]# systemctl restart php-fpm
至此,LNMP动态网站环境架构的配置实验全部结束。
五、搭建Discuz论坛
为了检验LNMP动态网站环境是否配置妥当,可以使用在上面部署Discuz!系统,然后查看结果。如果能够在LNMP动态网站环境中成功安装使用Discuz!论坛系统,也就意味着这套架构是可用的。Discuz! X3.2是国内最常见的社区论坛系统,在经过十多年的研发后已经成为了全球成熟度最高、覆盖率最广的论坛网站系统之一。
Discuz! X3.2软件包的后缀是.zip格式,因此应当使用专用的unzip命令来进行解压。解压后会在当前目录中出现一个名为upload的文件目录,这里面保存的就是Discuz!论坛的系统程序。我们把Nginx服务程序网站根目录的内容清空后,就可以把这些这个目录中的文件都复制进去了。记得把Nginx服务程序的网站根目录的所有者和所属组修改为本地的www用户(已在20.2.2小节创建),并为其赋予755权限以便于能够读、写、执行该论坛系统内的文件。
下面准备搭建WordPress博客。
[root@TradeProbe lnmp]# unzip Discuz_X3.2_SC_GBK.zip
[root@TradeProbe lnmp]# rm -rf /usr/local/nginx/html/{index.html,50x.html}*
[root@TradeProbe lnmp]# ll /usr/local/nginx/html/
总用量 0
drwxr-xr-x. 2 root root 6 6月 7 16:26 .
drwxr-xr-x. 11 root root 151 6月 6 23:20 ..
[root@TradeProbe lnmp]# mv upload/* /usr/local/nginx/html/
[root@TradeProbe lnmp]# chown -Rf nginxadmin:nginxadmin /usr/local/nginx/html
[root@TradeProbe lnmp]# chmod -Rf 777 /usr/local/nginx/html
检查Discuz! X3.2论坛系统的安装环境及目录权限。我们部署的LNMP动态网站环境版本和软件都与Discuz!论坛的要求相符合,如果图20-5框中的目录状态为不可写,请自行检查目录的所有者和所属组是否为www用户,以及是否对目录设置了755权限,然后单击“下一步”按钮。
选择“全新安装Discuz! X(含UCenter Server)”。UCenter Server是站点的管理平台,能够在多个站点之间同步会员账户及密码信息,单击“下一步”按钮,如图20-6所示。
填写服务器的数据库信息与论坛系统管理员信息。网站系统使用由服务器本地(localhost)提供的数据库服务,数据名称与数据表前缀可由用户自行填写,其中数据库的用户名和密码则为用于登录MySQL数据库的信息(以初始化MySQL服务程序时填写的信息为准)。论坛系统的管理员账户为今后登录、管理Discuz!论坛时使用的验证信息,其中账户可以设置得简单好记一些,但是要将密码设置得尽可能复杂一下。在信息填写正确后单击“下一步”按钮