php5.5.38 + Mysql-5.5.32 + Nginx-1.12.1 + centOS6.8_x64
一、首先,部署nginx
0x01 依旧接着我们之前准备好的系统继续,首先,将所有准备安装的源码包上传至服务器,软件包列表如下:1
2
3
4libiconv-1.14.tar.gz
mysql-5.5.32-linux2.6-x86_64.tar.gz
nginx-1.12.1.tar.gz
php-5.5.38.tar.gz
此次要实现的大致架构如下:1
php5.5.38 + mysql-5.5.32 + nginx-1.12.1 + centOS6.8_x64
0x02 开始编译安装nginx-1.10.3
安装所需的各种依赖库1
2
3
4# yum install pcre pcre-devel gcc gcc-c++ automake zlib zlib-devel openssl openssl-devel -y
# useradd -s /sbin/nologin -M nginx
# tar xf nginx-1.12.1.tar.gz
# cd nginx-1.12.1
1 | # ./configure --prefix=/usr/local/nginx-1.12.1 \ |
1 | # ln -s /usr/local/nginx-1.12.1/ /usr/local/nginx |
0x03 详细配置nginx
添加基于域名的虚拟主机,顺便测试url重写是否真正可用1
2
3# mkdir /usr/local/nginx/html/{bwapp,wp,discuz,drupal,joomla,phpcms,phpbb,dvwa} -p
# mkdir /usr/local/nginx/conf/extra && cd /usr/local/nginx/conf/extra
# touch bwapp.conf wp.conf discuz.conf drupal.conf joomla.conf phpcms.conf phpbb.conf dvwa.conf
1 | # vi /usr/local/nginx/conf/nginx.conf |
1 | # vi /usr/local/nginx/conf/extra/bwapp.conf |
1 | # /usr/local/nginx/sbin/nginx |
0x04 关于nginx访问日志轮询,可自行用shell实现
二,开始部署mysql,节省时间,我们还是直接用二进制包来配置部署1
2
3
4# useradd mysql -s /sbin/nologin -M
# tar xf mysql-5.5.32-linux2.6-x86_64.tar.gz
# mv mysql-5.5.32-linux2.6-x86_64 /usr/local/mysql-5.5.32
# ln -s /usr/local/mysql-5.5.32/ /usr/local/mysql
快速初始化mysql1
2
3
4
5
6
7
8
9# /usr/local/mysql/scripts/mysql_install_db --basedir=/usr/local/mysql --datadir=/usr/local/mysql/data/ --user=mysql
# chown -R mysql.mysql /usr/local/mysql/
# cp /usr/local/mysql/support-files/my-small.cnf /etc/my.cnf
# /usr/local/mysql/bin/mysqld_safe &
# echo "/usr/local/mysql/bin/mysqld_safe &" >> /etc/rc.local
# lsof -i :3306
# echo "export PATH=$PATH:/usr/local/mysql/bin/" >> /etc/profile
# source /etc/profile
# mysqladmin -uroot password "admin"
1 | # mysql -uroot -p |
三,部署php
安装各种依赖库1
2
3
4
5# yum install -y zlib-devel libxml2-devel libjpeg-devel freetype-devel libpng-devel gd-devel curl-devel libxslt-devel
# yum install epel-release -y
# yum install openssl openssl-devel libmcrypt libmcrypt-devel mcrypt mhash mhash-devel -y
# tar xf libiconv-1.14.tar.gz && cd libiconv-1.14
# ./configure --prefix=/usr/local/libiconv && make && make install
0x02 编译安装 php-5.5.381
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47# tar xf php-5.5.38.tar.gz
# cd php-5.5.38
# ./configure \
--prefix=/usr/local/php-5.5.38 \
--with-config-file-path=/usr/local/php-5.5.38/etc \
--with-mysql=/usr/local/mysql \
--with-mysqli=/usr/local/mysql/bin/mysql_config \
--with-pdo-mysql=/usr/local/mysql \
--with-iconv-dir=/usr/local/libiconv \
--with-freetype-dir \
--with-jpeg-dir \
--with-png-dir \
--with-zlib \
--with-libxml-dir=/usr \
--enable-xml \
--disable-rpath \
--enable-bcmath \
--enable-shmop \
--enable-sysvsem \
--enable-inline-optimization \
--with-curl \
--enable-mbregex \
--enable-fpm \
--enable-mbstring \
--with-mcrypt \
--with-gd \
--enable-gd-native-ttf \
--with-openssl \
--with-mhash \
--enable-pcntl \
--enable-sockets \
--with-xmlrpc \
--enable-soap \
--enable-short-tags \
--enable-static \
--with-xsl \
--with-fpm-user=nginx \
--with-fpm-group=nginx \
--enable-ftp \
--enable-opcache=no
# ln -s /usr/local/mysql/lib/libmysqlclient.so.18 /usr/lib64/
# touch ext/phar/phar.phar
# make && make install
# ln -s /usr/local/php-5.5.38/ /usr/local/php
# cp php.ini-production /usr/local/php/etc/php.ini
0x03 详细配置php-fpm1
2
3# mkdir /app/logs/ -p
# cd /usr/local/php/etc/
# cp php-fpm.conf.default php-fpm.conf
1 | # vi php-fpm.conf |
1 | # /usr/local/php/sbin/php-fpm |
0x04 让nginx解析php1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21# vi /usr/local/nginx/conf/extra/bwapp.conf
server {
listen 80;
server_name www.bwapp.org bwapp.org;
root html/bwapp/bWAPP;
location / {
index index.php index.html index.htm;
rewrite /adminer /hellohacker.html permanent;
}
location ~ .*\.(php|php5)?$ {
fastcgi_pass 127.0.0.1:9000;
fastcgi_index index.php;
include fastcgi.conf;
}
access_log logs/access_bwapp.log main;
error_page 500 502 503 504 /50x.html;
location = /50x.html {
root html/bwapp;
}
}
1 | # /usr/local/nginx/sbin/nginx -t |
四,最后,对环境进行全面可用性检测1
2
3
4
5
6
7安装bwapp 漏洞演练程序
安装dvwa 漏洞演练程序
安装 Discuz X3.2
安装drupal 7.56
安装 wordpress 4.8.1
安装 joomla 3.6.5
...
End
写脚本,写脚本,写脚本,重要的事情说三遍,或者更暴力一点,配好了以后直接打成rpm包,以后如果是完全相同的系统,直接全程yum即可,不然得烦死,另外,此环境仅作为自己学习之用,所以基本没做过任何加固处理,严禁直接参考用于实际生产环境中,否则,一切后果自负