nginx服务器搭建
yum 安装 nginx
yum install nginx -y
去掉ipv6地址监听
vim /etc/nginx/conf.d/default.conf
server {
listen 80 default_server;
# 注释掉ipv6地址监听
# 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
MySql的安装
yum 安装 MySql
yum install mysql-server -y
启动MySql服务
service mysqld restart
设置root用户的密码
/usr/bin/mysqladmin -u root password ‘123456’
设置开机启动项
chkconfig mysqld on
PHP的安装
yum install php php-fpm php-mysql -y
php-fpm启动
service php-fpm start
查看php-fpm监听的端口
netstat -nlpt | grep php-fpm
设置php-fpm为启动项
chkconfig php-fpm on
新建站点测试
vim /etc/nginx/conf.d/php.conf
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;
}
}
重启nginx
service nginx restart
新建php文件
vim /usr/share/php/info.php
<?php phpinfo(); ?>