更新源
apt-get update
安装nginx
apt-get install nginx
主配置文件
cd /etc/nginx/nginx.conf
和lamp一样
把sites-available里的链接到sites-enabled里则生效
也是在/var/www/里创建站点
修改站点文件
vim /etc/nginx/sites-enabled
server {
listen 80;#改了这里
# SSL configuration
#
# listen 443 ssl default_server;
# listen [::]:443 ssl default_server;
#
# Note: You should disable gzip for SSL traffic.
# See: https://bugs.debian.org/773332
#
# Read up on ssl_ciphers to ensure a secure configuration.
# See: https://bugs.debian.org/765782
#
# Self signed certs generated by the ssl-cert package
# Don't use them in a production server!
#
# include snippets/snakeoil.conf;
root /var/www/gaohang.name;#改了这里
# Add index.php to the list if you are using PHP
index index.html index.htm index.nginx-debian.html;
server_name gaohang.name;#改了这里
重启nginx命令
nginx -s reload
安装时检查是否出错
nginx -t
修改hosts文件
打开vim /etc/hosts
添加 IP 站点名字
192.168.20.10 gaohang.name
nginx 服务器重启命令,关闭
nginx -s reload :修改配置后重新加载生效
nginx -s reopen :重新打开日志文件
nginx -t -c /path/to/nginx.conf 测试nginx配置文件是否正确
关闭nginx:
nginx -s stop :快速停止nginx
quit :完整有序的停止nginx
其他的停止nginx 方式:
ps -ef | grep nginx
kill -QUIT 主进程号 :从容停止Nginx
kill -TERM 主进程号 :快速停止Nginx
pkill -9 nginx :强制停止Nginx
安装php支持
apt-get install php-fpm
apt-get install php-redis