环境
一台centos7LAMP架构可处理动态页面 20.0.0.110nat模式
一台centos7Nginx服务器主要负责处理静态页面20.0.0.31 nat模式
一台Windows10客户端20.0.0.85 nat模式
配置
LAMP
Apache
[root@localhost ~]#yum -y install httpd httpd-devel
[root@localhost ~]#firewall-cmd --permanent --zone=public --add-service=http
[root@localhost ~]#firewall-cmd --permanent --zone=public --add-service=https
[root@localhost ~]#firewall-cmd --reload
[root@localhost ~]#systemctl start httpd
可以去客户端访问一下20.0.0.110,测试下Apache
数据库mariadb
[root@localhost ~]#yum -y install mariadb mariadb-server mariadb mariadb-libs mariadb-devel -y
[root@localhost ~]#systemctl start mariadb
[root@localhost ~]#mysql_secure_installation
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 ##设置root密码
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] n ##不移除匿名用户
... skipping.
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] n ##允许远程登录
... skipping.
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 ##允许测试数据库和访问它
... 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!
[root@localhost ~]#
PHP
[root@localhost ~]# yum -y install php php-mysql
[root@localhost ~]# yum -y install php-gd php-ldap php-odbc php-pear php-xml php-xmlrpc php-mbstring php-snmp php-soap curl curl-devel php-bcmath
[root@localhost ~]# cd /var/www/html
[root@localhost html]# vim index.php
<?php
phpinfo();
?>
[root@localhost ~]#
这样LAMP就搭建好了,可以去客户端访问20.0.0.110
Nginx
安装还是一样安装,可参考nginx部分
修改下配置文件
[root@nginx ~]# vim /usr/local/nginx/conf/nginx.conf
...
# proxy the PHP scripts to Apache listening on 127.0.0.1:80
#
location ~ \.php$ { ##开启代理模块,将PHP的请求转交给20.0.0.110
proxy_pass http://20.0.0.110;
}
# pass the PHP scripts t
...
[root@nginx ~]#systemctl start nginx
测试
可以去客户端测试访问20.0.0.31,可看到nginx的页面,你们的应该是没有那种小熊的,因为我是接着上此的做的,之前配置过
访问20.0.0.31/index.php可看到PHP的页面,这是转交给20.0.0.110处理的页面
相关工具
相关软件包