本文主要是介绍【运维】ubuntu16.04安装lnmp:nginx1.10 mysql5.7 php5.6,希望对大家解决编程问题提供一定的参考价值,需要的开发者们随着小编来一起学习吧!
花了一个多小时重新在ubuntu16.04中装了lnmp:Linux kernel 4.9.93 nginx1.10 mysql5.7 php5.6。
手动配置nginx+php之前没搞过,看这个学到了一点新知识:https://blog.csdn.net/dengjiexian123/article/details/53358452
此外,还发现了一个不错的资源,nginx中文文档https://wizardforcel.gitbooks.io/nginx-doc/content/Text/6.5_nginx_php_fpm.html
安装
安装lnmp:nginx1.10 mysql5.7 php5.6 最新代码可以参考:https://gist.github.com/thinkycx/bd78072e35e833cd7538f9afaefc6086
# tools
sudo apt-get install lsof -y# =====================================================================
# 1.nginx
sudo apt-get install nginx -y# nginx start
# sudo /etc/init.d/nginx start
# sudo service nginx start# nginx show
# dpkg -S nginx # nginx see which conf used
# nginx -t# reference
# https://blog.csdn.net/STFPHP/article/details/53492723# =====================================================================# 2 php# uninstall old php related files
# sudo apt-get purge `dpkg -l | grep php| awk '{print $2}' |tr "\n" " "`\
# install add-apt-repository
sudo apt-get install software-properties-common -y
sudo add-apt-repository ppa:ondrej/php -y
# maybe need to fix
# apt-key adv --keyserver keyserver.ubuntu.com --recv-keys 4F4EA0AAE5267A6C
# see https://blog.csdn.net/think_ycx/article/details/84198255
sudo apt-get update -ysudo apt-get install php5.6 -y
# optional php modules
# sudo apt-get install php5.6-mbstring php5.6-mcrypt php5.6-mysql php5.6-xml
# sudo php -v# references
# Installing PHP 5.6 on Xenial (16.04) [duplicate] https://askubuntu.com/questions/756181/installing-php-5-6-on-xenial-16-04# =====================================================================
# 3. mysql
# mysql install
sudo apt-get install mysql-server
sudo apt install mysql-client
sudo apt install libmysqlclient-dev #Connector/C (libmysqlclient) is a client library for C development.# mysql start
# service mysql start# mysql see if is running
# netstat -tap | grep mysql# =====================================================================
# 4. nginx-php # php-fpm
apt-get install php5.6-fpm
sudo service php-fpm start# check status
# $ netstat -ano |grep fpm
# unix 2 [ ACC ] STREAM LISTENING 186389 /run/php/php5.6-fpm.sock# php-fpm change nginx conf
# change file in /etc/nginx/sites-enabled/default
# add php5.6
: '# 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;# # With php7.0-fpm:# fastcgi_pass unix:/run/php/php7.0-fpm.sock;# }# php 5.6 20181118 by thinkycxlocation ~ \.php$ {include snippets/fastcgi-php.conf;fastcgi_pass unix:/run/php/php5.6-fpm.sock;}
'# test
# echo "<?php\n phpinfo(); " > /var/www/html/1.php
# curl http://localhost/1.php# reference
# 1. https://blog.csdn.net/dengjiexian123/article/details/53358452# =====================================================================
# 5. test php-mysql# php and mysql connect
# install
sudo apt-get install php5.6-mysql # test
curl localhost/db.php
: '
$ cat db.php
<?php
$servername = 'localhost';
$username = 'root';
$password = 'root';
$database='flag';
$conn = new mysqli($servername, $username, $password,$database);
if ($conn->connect_error) {die("Connection failed: " . $conn->connect_error);
}
echo "Connected successfully";
'
这篇关于【运维】ubuntu16.04安装lnmp:nginx1.10 mysql5.7 php5.6的文章就介绍到这儿,希望我们推荐的文章对编程师们有所帮助!