一起牛网_苹果安卓手游族群聚集地!
发布时间:2021-06-27 14:36:04来源:一起牛手游网作者:一起牛手游网
确保你的系统为最新版本:
yum update
最快最容易安装Nginx的方式是使用第三方源EPEL
sudo yum install epel-release
yum update
yum install nginx
这些命令指安装EPEL仓库,拉取最新的metadata,之后安装Nginx
Nginx安装完成后,需要在systemd激活和启动,可以使用systemctl命令来做
systemctl enable nginx.service
systemctl start nginx.service
然后你可以检查其状态确保nginx始终启动
systemctl status nginx.service
一旦nginx安装完成,你需要在配置文件配置server块。每个server块需要一个server和location指令。你可以把server块分别建立不同文件,或者直接放到一个文件/etc/nginx/nginx.conf。在这个例子里,我们使用多个配置文件。默认地,Nginx会引用/etc/nginx/conf.d目录下的.conf文件
/etc/nginx/conf.d/example.com.conf:
server {
listen 80;
server_name www.example.com example.com;
access_log /var/www/example.com/logs/access.log;
error_log /var/www/example.com/logs/error.log;
location / {
root /var/www/example.com/public_html;
index index.html index.htm index.php;
}
}
你想托管额外的网站时,可以把配置文件放在/etc/nginx/conf.d目录。一旦建立好配置文件,你需要为你的public html文件,日志目录创建目录:
mkdir -p /var/www/example.com/{public_html,logs}
配置文件虚拟主机后,需要重启nginx以生效配置
systemctl restart nginx.service
如果你的网站是PHP写的,你需要实现PHP-FastCGI以便能让Nginx能正确地处理和解析PHP代码。你可以从EPEL仓库使用YUM安装
yum install php-cli php spawn-fcgi
PHP-FastCGI安装好后,需要创建一个用来启动和控制php-cgi进程的脚本。
/usr/bin/php-fastcgi:
#!/bin/sh
if [ `grep -c "nginx" /etc/passwd` = "1" ]; then
FASTCGI_USER=nginx
elif [ `grep -c "www-data" /etc/passwd` = "1" ]; then
FASTCGI_USER=www-data
elif [ `grep -c "http" /etc/passwd` = "1" ]; then
FASTCGI_USER=http
else
# Set the FASTCGI_USER variable below to the user that
# you want to run the php-fastcgi processes as
FASTCGI_USER=
fi
/usr/bin/spawn-fcgi -a 127.0.0.1 -p 9000 -C 6 -u $FASTCGI_USER -f /usr/bin/php-cgi
脚本创建好后,设置其有执行权限
chmod +x /usr/bin/php-fastcgi
PHP-FastCGI安装好后,它不会自动地在systemd注册为服务。如果你想用systemd更方便地管理PHP-FastCGI,可以把它配置为systemd服务。需要创建一个服务文件指向/usr/bin/php-fastcgi:
/etc/systemd/system/php-fastcgi.service:
[Unit]
Description=php-fastcgi systemd service script
[Service]
Type=forking
ExecStart=/usr/bin/php-fastcgi start
[Install]
WantedBy=multi-user.target
服务文件创建好后,需要重载systemd守护进程以激活此服务,然后启动它。
systemctl daemon-reload
systemctl enable php-fastcgi.service
systemctl start php-fastcgi.service
CentOS 7官方源已经没有MySQL了,已经用MariaDB替代,不过放心,这个是完全兼容MySQL的,用法一样。
1.从官方源安装MariaDB
yum install mariadb-server
2.安装完成后,使用systemctl来激活并启动mariadb
systemctl enable mariadb.service
systemctl start mariadb.service
3.使用mysql_secure_installation命令来加固MariaDB
mysql_secure_installation
到此LEMP安装完成。
食物语手游腊味合蒸高阶阵容打法思路一览
神雕侠侣2手游氪金玩家消费指南
王牌战士幽灵实战技巧讲解
爱江山更爱美人游戏中宫论战攻略
王牌战士团战如何切入详细讲解
和平精英通讯塔是什么 和平精英通讯塔玩法详细解析
暴走英雄坛延生保命丹怎么用 延生保命丹平民用法攻略
凌烟诀新手前期武学学习与主线攻略
梦幻西游三维版每日日常活动任务安排流程攻略
王者荣耀
角色扮演
坠落星界
其它游戏
炽姬无双
角色扮演
梦三国
角色扮演
跑跑卡丁车官方竞速版
体育竞技
邪恶疯人院
休闲益智
征途永恒
角色扮演
传奇世界3D
角色扮演
一刀传世
角色扮演