微信公众号搜"智元新知"关注
微信扫一扫可直接关注哦!

CentOS上编译安装Nginx、PHP、MySQL

 

一、编译安装Nginx

# cd /usr/local/src

# wget http://Nginx.org/download/Nginx-1.16.0.tar.gz

# tar -zxvf Nginx-1.16.0.tar.gz

# cd Nginx-1.16.0

# yum install -y gcc-c++ pcre pcre-devel zlib zlib-devel openssl openssl-devel

# ./configure --prefix=/usr/local/Nginx --sbin-path=/usr/local/Nginx/sbin/Nginx --conf-path=/usr/local/Nginx/conf/Nginx.conf --pid-path=/usr/local/Nginx/run/Nginx.pid --lock-path=/usr/local/Nginx/run/Nginx.lock --http-client-body-temp-path=/usr/local/Nginx/run/client_body_temp --http-proxy-temp-path=/usr/local/Nginx/run/proxy_temp --http-fastcgi-temp-path=/usr/local/Nginx/run/fastcgi_temp --http-uwsgi-temp-path=/usr/local/Nginx/run/uwsgi_temp --http-scgi-temp-path=/usr/local/Nginx/run/scgi_temp --http-log-path=/usr/local/Nginx/log/access.log --error-log-path=/usr/local/Nginx/log/error.log --with-debug --with-http_addition_module --with-http_auth_request_module --with-http_dav_module --with-http_degradation_module --with-http_flv_module --with-http_gunzip_module --with-http_gzip_static_module --with-http_mp4_module --with-http_random_index_module --with-http_realip_module --with-http_secure_link_module --with-http_slice_module --with-http_ssl_module --with-http_stub_status_module --with-http_sub_module --with-http_v2_module --with-mail --with-mail_ssl_module --with-pcre --with-pcre-jit --with-stream --with-stream_realip_module --with-stream_ssl_module --with-stream_ssl_preread_module
# make
# make install

安装完毕,启动/关闭/重启Nginx命令如下:

# /usr/local/Nginx/sbin/Nginx //启动
# /usr/local/Nginx/sbin/Nginx -s stop //关闭
# /usr/local/Nginx/sbin/Nginx -s reload //重启
附带:查看启动状态
# ps -ef | grep Nginx

设置Nginx开机启动(参考自:https://www.jianshu.com/p/ca5ee5f7075c

# vi /usr/lib/systemd/system/Nginx.service

# 在文件中写入启动脚本
[Unit]
Description=Nginx
After=network.target

[Service]
Type=forking
ExecStart=/usr/local/Nginx/sbin/Nginx
ExecStop=/usr/local/Nginx/sbin/Nginx -s stop
ExecReload=/usr/local/Nginx/sbin/Nginx -s reload
PrivateTmp=true

[Install]
WantedBy=multi-user.target

保存上述脚本文件,然后设置Nginx开机启动

# systemctl enable Nginx.service

重启系统

# reboot

查看Nginx是否开机启动成功,在浏览器输入:http://localhost

 

二、编译安装PHP 7.4

# cd /usr/local/src

 

版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 [email protected] 举报,一经查实,本站将立刻删除。

相关推荐