Ubuntu16.0.4.1安装lnmp

前端之家收集整理的这篇文章主要介绍了Ubuntu16.0.4.1安装lnmp前端之家小编觉得挺不错的,现在分享给大家,也给大家做个参考。

环境:

系统:Ubuntu16.0.4.1

内核:Linux os 4.7.10-040710-generic #201610220847 SMP Sat Oct 22 12:50:14 UTC 2016 x86_64 x86_64 x86_64 GNU/Linux (想升级内核可以看前篇文章

apt方式安装

首先安装:Nginx

apt install Nginx

启动sudo /etc/init.d/Nginx start

网页输入127.0.0.1测试

安装数据库

sudo apt-get install MysqL-server

会弹出一个输入MysqL管理员密码,输入即可.

sudoapt-get-yinstallPHP7.0
sudoapt-get-yinstallPHP7.0-MysqL
sudoapt-getinstallPHP7.0-fpm

apt-getinstallPHP7.0-curlPHP7.0-xmlPHP7.0-mcryptPHP7.0-jsonPHP7.0-gdPHP7.0-mbstringPHP-xml

#sudo vim /etc/PHP/7.0/fpm/PHP.ini (最好先备份PHP.ini)

cgi.fix_pathinfo=1 这行去注释,1改成0

#sudo vim /etc/PHP/7.0/fpm/pool.d/www.conf

修改

listen=/var/run/PHP7.0-fpm.sock 或者 listen = 127.0.0.1 (若此方式,则下面的default配置文件需要改成一样)

#sudo vim /etc/Nginx/sites-available/default (最好先备份default)

修改了以下配置,红色部分

root /var/www/html;


# Add index.PHP to the list if you are using PHP

index index.PHP index.html index.htm index.Nginx-debian.html;


#server_name _;

server_name loclhost;


location / {

# First attempt to serve request as file,then

# as directory,then fall back to displaying a 404.

try_files $uri $uri/ =404;

}


# pass the PHP scripts to FastCGI server listening on 127.0.0.1:9000

#

location ~ \.PHP$ {

# include snippets/fastcgi-PHP.conf;

# # With PHP7.0-cgi alone:

# fastcgi_pass 127.0.0.1:9000; (对应www.conf中listen ,这里开启则注释下面fastcgi_pass unix

# # With PHP7.0-fpm:

fastcgi_pass unix:/var/run/PHP/PHP7.0-fpm.sock;

fastcgi_index index.PHP;

fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;

include fastcgi_params;

}


然后重启服务

/etc/init.d/Nginx restart

/etc/init.d/PHP7.0-fpm restart

查看服务是否配置成功

sudo vim /var/www/html/index.PHP

<?PHP

PHPinfo();

?>

然后127.0.0.1/index.PHP

若有错误请查看日志文件

cd /var/log/

原文链接:https://www.f2er.com/ubuntu/354728.html

猜你在找的Ubuntu相关文章