搭建nginx环境(参考腾讯云实验室)
使用 yum
安装 Nginx:
yum install nginx -y
修改 /etc/nginx/conf.d/default.conf,去除对 IPv6 地址的监听,可参考下面的代码示例:
server {
listen 80 default_server;
# listen [::]:80 default_server;
server_name _;
root /usr/share/nginx/html;
# Load configuration files for the default server block.
include /etc/nginx/default.d/*.conf;
location / {
}
error_page 404 /404.html;
location = /40x.html {
}
error_page 500 502 503 504 /50x.html;
location = /50x.html {
}
}
修改完成后,启动 Nginx:
nginx
chkconfig nginx on
yum
安装 MySQL:yum install mysql-server -y
service mysqld restart
chkconfig mysqld on
yum
安装 PHP:yum install php php-fpm php-mysql -y
service php-fpm start
netstat -nlpt | grep php-fpm
chkconfig php-fpm on
server {
listen 8000;
# pass the PHP scripts to FastCGI server listening on 127.0.0.1:9000
location ~ .php$ {
root /usr/share/php;
fastcgi_pass 127.0.0.1:9000;
fastcgi_index index.php;
fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
include fastcgi_params;
}
}
service nginx restart