sudo apt-get install nginx
开启服务
检查版本:
nginx –v
启动服务:
sudo nginx
sudo service nginx start
关闭服务:
sudo nginx -s stop
sudo service nginx stop
重启:
sudo nginx -s reload
sudo apt install mysql-server mysql-client
mysql -server
ERROR 2002 (HY000): Can’t connect to local MySQL server through socket
‘/var/run/mysqld/mysqld.sock’
sudo mkdir -p /var/run/mysqld
sudo chown mysql /var/run/mysqld/
sudo service mysql restart
mysql -u root -p
解决方案:
步骤一:登录mysql
sudo mysql -u root -p
步骤二:修改密码
update mysql.user set authentication_string=PASSWORD('123'), plugin='mysql_native_password' where user='root';
步骤二:重启服务
flush privileges;
sudo apt-add-repository ppa:ondrej/php ###使用 PPA ppa:ondrej/php
sudo apt update ###更新软件库
sudo apt install php7.0 php7.0-fpm php7.0-cgi php7.0-common php7.0-curl php7.0-mysql php7.0-mcrypt php7.0-mbstring
sudo vim /etc/php/7.0/fpm/pool.d/www.conf
listen = /run/php/php7.0-fpm.sock
#listen = 127.0.0.1:9000
查看监听路径是否存在,不存在则手动追加/run/php/,否则无法生成php-fpm.socket
可以用如下方式检查下配置文件是否有错误 sudo php-fpm7.0 -t
修改重启下 sudo service php7.0-fpm restart
sudo vim /etc/nginx/sites-enabled/default
server {
listen 80 default_server;
listen [::]:80 default_server;
root /var/www;
# Add index.php to the list if you are using PHP
#追加index.php
index index.php index.html index.htm index.nginx-debian.html;
server_name _;
location / {
# First attempt to serve request as file, then
# as directory, then fall back to displaying a 404.
try_files $uri $uri/ =404;
}
# pass PHP scripts to FastCGI server
#
location ~ \.php$ {
include snippets/fastcgi-php.conf;
# With php-fpm (or other unix sockets):
#此处路径必须与php-fpm配置相同
fastcgi_pass unix:/run/php/php7.0-fpm.sock;
# With php-cgi (or other tcp sockets):
#fastcgi_pass 127.0.0.1:9000;
}
nginx 检查配置文件命令是 sudo nginx -t
修改重启下 nginx sudo service nginx restart