安裝php:
sudo apt install php7.0 php7.0-mbstring php7.0-gd php7.0-mbstring php7.0-mysql php7.0-fpm
php
sudo apt install php7.2 php7.2-mbstring php7.2-gd php7.2-mbstring php7.2-mysql php7.2-fpm #2019-5-3安裝
安裝MariaDB:
$ sudo apt install mariadb-server
啓動MariaDB服務:
$ sudo systemctl restart mysql
初始化MariaDB
$ sudo mysql_secure_installation
默認root密碼爲空;而後設置root密碼和其餘選項:html
修改php-fpm的配置文件mysql
vim /etc/php/7.0/fpm/pool.d/www.confnginx
;listen = /tmp/php-fcgi.sock listen = 127.0.0.1:9000
修改nginx的配置文件sql
sudo vim /etc/nginx/sites-enabled/default
vim
## # You should look at the following URL's in order to grasp a solid understanding # of Nginx configuration files in order to fully unleash the power of Nginx. # http://wiki.nginx.org/Pitfalls # http://wiki.nginx.org/QuickStart # http://wiki.nginx.org/Configuration # # Generally, you will want to move this file somewhere, and start with a clean # file but keep this around for reference. Or just disable in sites-enabled. # # Please see /usr/share/doc/nginx-doc/examples/ for more detailed examples. ## # Default server configuration # server { listen 80; server_name liveknight.xyz; index index.php; root /var/www/html/dream/public/; location / { if (!-e $request_filename) { rewrite ^/(.*)$ /index.php/$1 last; break; } } location ~ \.php { fastcgi_pass 127.0.0.1:9000; fastcgi_index index.php; include fastcgi_params; set $real_script_name $fastcgi_script_name; if ($fastcgi_script_name ~ "^(.+?\.php)(/.+)$") { set $real_script_name $1; set $path_info $2; } fastcgi_param SCRIPT_FILENAME $document_root$real_script_name; fastcgi_param SCRIPT_NAME $real_script_name; fastcgi_param PATH_INFO $path_info; } } # Virtual Host configuration for example.com # # You can move that to a different file under sites-available/ and symlink that # to sites-enabled/ to enable it. # #server { # listen 80; # listen [::]:80; # # server_name example.com; # # root /var/www/example.com; # index index.html; # # location / { # try_files $uri $uri/ =404; # } #}
#設置開機自啓php7
$ sudo systemctl enable mysql $ sudo systemctl enable php7.2-fpm $ sudo systemctl enable nginx
報錯 403
sudo chmod -R 775 /var/www/htmlphp-fpm