1、安装及运行控制
? ? ? ? ?(1)安装yum及pcre,zlib软件开发包 插入1611光盘
rm -rf /etc/yum.repos.d/*
vim /etc/yum.repos.d/a.repo
[a]
name=a
baseurl=file:///media
gpgcheck=0
yum -y install pcre-devel zlib-devel
? ? ? ? (2)创建运行账户、组
useradd -M -s /sbin/nologin nginx
? ? ? ? (3)编译及安装Nginx 插入LNMP光盘
tar zxf nginx-1.12.0.tar.gz -C /usr/src/
cd /usr/src/nginx-1.12.0/
./configure --prefix=/usr/local/nginx --user=nginx --group=nginx --with-http_stub_status_module
make && make install
? ? ? ? (4)为主程序Nginx创建链接文件
ln -s /usr/local/nginx/sbin/nginx /usr/local/sbin/
ls -l /usr/local/sbin/nginx
? ? ? ? (5)检查配置文件及启动,停止Nginx
nginx -t (检查,看见OK即可)
nginx (开启Nginx服务)
netstat -anpt | grep nginx (查看Nginx是否开启)
killall -s HUP nginx (重新加载服务)
killall -s QUIT nginx (停止服务)
2、访问状态统计及虚拟主机应用
? ? ? ? (1)I/O?事件配置
vim /usr/local/nginx/conf/nginx.conf
(在events{ }中添加)
use epoll; (使用epll模型)
worker_connections 4096; (每个进程处理4096个链接)
? ? ? ? (2)Nginx的访问统计状态统计
vim /usr/local/nginx/conf/nginx.conf
log_format main '$remote_addr - $remote_user [$time_local] "$request" '
'$status $body_bytes_sent "$http_referer" '
'"$http_user_agent" "$http_x_forwarded_for"';
(以上去掉注释#)
(在下列server { }中修改及添加)
server_name www.yy.com; (网站名称)
charset utf-8; (网站的默认字符集)
index index.html index.php; (默认首页)
location /status { (访问位置为status)
stub_status on; (打开统计功能)
access_log off; (关闭此位置的日志记录)
}
nginx -t
killall -s HUP nginx
? ? ? ? (3)访问Nginx服务的/status网站位置?
3、基于域名的虚拟Web主机?
? ? ? ? (1)dns配置?
安装包 插入1661光盘
yum -y install bind bind-chroot.x86_64
? ? ? ? (2)dns主配置文件
vim /etc/named.conf
(删除以下两行)
listen-on port 53 { 127.0.0.1; };
allow-query { localhost; };
以下为添加
zone "benet.com" in {
type master;
file "benet.com.zone";
};
zone "yy.com" in {
type master;
file "yy.com.zone";
};
? ? ? ? (3)区域数据文件
vim /var/named/benet.com.zone
$ttl 86400
@ in soa benet.com. admin.benet.com. (
20220202
3h
15m
1w
1d
)
in ns ns1.benet.com.
ns1 in a 192.168.1.10
www in a 192.168.1.10
vim /var/named/yy.com.zone
$ttl 86400
@ in soa yy.com. admin.yy.com. (
20220202
3h
15m
1w
1d
)
in ns ns1.yy.com.
ns1 in a 192.168.1.10
www in a 192.168.1.10
????????(4)重启?、排错、检查正向和反向数据文件
systemctl restart named (重启)
named-checkconf -z /etc/named.conf (排错)
named-checkzone benet.com /var/named/benet.com.zone (检查正向和反向数据文件)
??????(5)为两个虚拟web主机建立根目录
mkdir -p /var/www/benet
echo "<h1>www.benet.com</h1>" > /var/www/benet/index.html
mkdir -p /var/www/yy
echo "<h1>www.yy.com</h1>" > /var/www/yy/index.html
? ? ? ? (6)调整nginx.conf配置文件.配置两个’server { )“区域分别对应两个Web站点 指定各自的网站名称、监听地址、网站根目录访问日志等信息。然后重载配置.
vim /usr/local/nginx/conf/nginx.conf
access_log logs/yy.access.log main;
root /var/www/yy; (修改网站跟目录的位置)
(在下方模板修改)
server {
listen 80;
server_name www.benet.com;
charset utf-8;
access_log logs/benet.access.log main;
location / {
root /var/www/benet;
index index.html index.php;
}
}
nginx -t (检查语法)
killall -s HUP nginx (重新加载服务)
? ? ? ? ?(7)配置客户端ip地址及dns ip为192.168.1.254,dns指向服务器192.168.1.10
????????(8)客户端访问不同的站点
3、构建LNMP (LNEP)网站平台
??????? (1)启动MySQL服务
systemctl restart mysqld
mysqladmin -u root password 'pwd123' (为root用户设置密码)
??????? (2)安装PHP解析环境 插入1611光盘
yum -y install gd libxml2-devel.x86_64 libjpeg-devel libpng-devel.x86_64
插入LNMP光盘,编译安装PHP
tar zxf php-5.5.38.tar.gz -C /usr/src/
cd /usr/src/php-5.5.38/
./configure --prefix=/usr/local/php5 --with-gd --with-zlib --with-mysql=/usr/local/mysql --with-mysqli=/usr/local/mysql/bin/mysql_config --with-config-file-path=/usr/local/php5 --enable-mbstring --enable-fpm --with-jpeg-dir=/usr/lib
make && make install
?安装后的调整
cp php.ini-development /usr/local/php5/php.ini
ln -s /usr/local/php5/bin/* /usr/local/bin/
ln -s /usr/local/php5/sbin/* /usr/local/sbin/
??????? (3) 安装ZendGuardLoader
tar zxf zend-loader-php5.5-linux-x86_64_update1.tar.gz -C /usr/src/
cd /usr/src/zend-loader-php5.5-linux-x86_64/
cp ZendGuardLoader.so /usr/local/php5/lib/php
vim /usr/local/php5/php.ini
zend_extension=/usr/local/php5/lib/php/ZendGuardLoader.so
zend_loader.enable=1
???????? (4)配置Nginx支持PHP环境 通过使用PHP的fpm模块来调用本机的php环境
cd /usr/local/php5/etc/
cp php-fpm.conf.default php-fpm.conf
useradd -M -s /sbin/nologin php
vim php-fpm.conf
pid = run/php-fpm.pid (确认pdi文件位置)
user = php (运行用户)
group = php (运行组)
pm.start_servers = 20 (启动时开启的进程数)
pm.max_children = 50 (最多的进程数)
pm.min_spare_servers = 5 (最少的空闲进程数)
pm.max_spare_servers = 35 (最多空闲进程数)
/usr/local/sbin/php-fpm (启动)
netstat -anpt | grep php-fpm (查看端口)
??????? (5)调用本机的php-fpm进程
vim /usr/local/nginx/conf/nginx.conf
location ~ \.php$ {
root /var/www/yy;
fastcgi_pass 127.0.0.1:9000;
fastcgi_index index.php;
include fastcgi.conf;
}
nginx -t
killall -s HUP nginx
??????? (6)PHP也没访问测试
vim /var/www/yy/test.php
<?php
$link=mysqli_connect('localhost','root','pwd123');
if($link) echo "<h1>1111111111</h1>";
mysqli_close ($link);
?>
?访问测试网页www.yy.com.test.php
?4、在LNMP平台中部署web应用
???????? (1)下载并部署程序代码 插入LNMP光盘
cd /media/
cp Discuz_X3.3_SC_UTF8.zip /usr/src/
cd /usr/src/
unzip Discuz_X3.3_SC_UTF8.zip
mv upload/ /var/www/yy/bbs
chown -R php:php /var/www/yy/bbs
??????? (2)创建数据库
mysql -uroot -p
(输入密码pwd123)
create database bbs;
grant all on bbs.* to runbbs@localhost identified by 'bbs@yh123';
??????? (3)安装web应用 访问www.yy.com/bbs/install/index.php
?
安装完成后通过访问www.yy.com/bbs/forum.php可以看到论坛首页 www.yy.com/bbs/admin.php,可以用管理员账户进入管理后台
|