环境
Ubuntu 16.04 i386
Nginx
安装Nginx
$ apt-get update
$ apt-get install nginx
访问你的主机IP
http://server_domain_or_IP
如果出现下图则证明安装成功.
MySQL
安装MySQL
$ apt-get install mysql-server
输入Root管理用户密码后安装完成。
PHP 7
安装php7.0
$ apt-get -y install php7.0-fpm php-mysql
PHP fix_pathinfo 潜在安全漏洞修复,在/etc/php/7.0/fpm/php.ini中找到
;cgi.fix_pathinfo=1
改为
cgi.fix_pathinfo=0
重启 php
$ systemctl restart php7.0-fpm
在/etc/nginx/sites-available/default 中添加配置
server {
listen 80;
listen [::]:80;
# listen [::]:443 ssl http2;
# listen 443 ssl http2;
# include ssl.conf;
# ssl_certificate /path/to/crt;
# ssl_certificate_key /path/to/key;
root /var/www/server_domain_or_IP;
index index.html index.htm index.php;
server_name server_domain_or_IP;
location / {
try_files $uri $uri/ =404;
}
location /phpmyadmin {
index index.php;
}
location ~ \.php$ {
include snippets/fastcgi-php.conf;
fastcgi_pass unix:/run/php/php7.0-fpm.sock;
}
location ~ /\.ht {
deny all;
}
}
重启Nginx
$ systemctl restart nginx
测试PHP是否已完成安装配置,编辑/var/www/html/info.php
$ vi /var/www/html/info.php
添加内容
<?php
phpinfo();
?>
然后访问
http://server_domain_or_IP/info.php
出现下图则安装配置成功
使用phpMyAdmin管理MySQL
安装phpMyAdmin
$ apt-get update
$ apt-get install phpmyadmin php-mbstring php-gettext
创建链接
$ ln -s /usr/share/phpmyadmin/ /var/www/html/
重启Nginx
$ systemctl restart nginx
访问
http://server_domain_or_IP/phpmyadmin
出现下图则安装配置成功
网友评论