配置nginx
1) 启动nginx服务:
service nginx restart
2) 测试nginx服务是否正常运行:
wget http://127.0.0.1
最后显示" 'index.html' saved ",说明nginx服务正常。
3)在浏览器中,访问通过CentOS云服务器公网IP查看nginx服务是否正常运行
配置PHP
1) 启动php-fpm:
service php-fpm start
2) 修改php-fpm和nginx的配置,实现nginx和php联动:
cat /etc/php-fpm.d/www.conf |grep -i 'listen ='
返回结果为:listen = 127.0.0.1:9000
以上结果表明php-fpm的默认配置的监听端口为9000,现在只用修改配置,将php解 析的请求转发到127.0.0.0:9000处理即可。
使用以下命令查找nginx配置文件:
nginx -t
并使用vi命令修改该配置文件
在配置文件中找到以下片段,修改粗体部分
server {
listen 80;
root /usr/share/nginx/html;
server_name localhost;
#charset koi8-r;
#access_log /var/log/nginx/log/host.access.log main;
location / {
index index.html index.htm;
}
#error_page 404 /404.html;
# redirect server error pages to the static page /50x.html
#
error_page 500 502 503 504 /50x.html;
location = /50x.html {
root /usr/share/nginx/html;
}
# pass the PHP scripts to FastCGI server listening on 127.0.0.1:9000
#
location ~ .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
环境配置验证
vim /usr/share/nginx/html/index.php
写入:<?phpecho "<title>Test Page</title>";echo "hello world";?>
在浏览器中,访问CentOS云服务器公网IP查看环境配置是否成功,如果页面可以显示“hello world”,说明配置成功。
mysql自己安装