ubuntu配置nginx+php开发环境(virtualbox)
A.安装环境
1.安装php7.0
sudo apt install php7.0
2.安装php7.0-fpm,这是php和nginx之间的连接器。
sudo apt install php7.0-fpm
3.安装php7.0-dev和php7.0-mysql
sudo apt install php7.0-dev
sudo apt install php7.0-mysql
4.安装正则表达式库pcre
sudo apt install libpcre32-3
5.安装php curl
sudo apt-get install php7.0-curl
sudo service nginx restart
5.安装php curl php7.0-soap
sudo apt-get install php7.0-soap
Php.ini文件:可以打开错误提示,可以及时发现错误,并进行调试
nano /etc/php/7.2/fpm/php.ini
Ctr+w :search
B.配置文件
配置Nginx和Php7.0-FPM 启用php7.0-FPM服务并在Nginx中生效
1.找到:etc/nginx/sites-available/default(/etc/nginx/sites-available/chery.gcmasia.com)
location ~ \.php$ {
include snippets/fastcgi-php.conf;
fastcgi_pass unix:/run/php/php7.0-fpm.sock;
#~ # With php7.0-cgi alone:
#~ fastcgi_pass 127.0.0.1:9000;
#~ # With php7.0-fpm:
}
2.找到:/etc/php/7.0/fpm/php-fpm.conf,
在文件末尾加:listen = /run/php/php7.0-fpm.sock
C.测试环境
1. sudo service php7.0-fpm start
2. sudo service ngnix start
<?Php phpinfo(); ?>
删除phpmyadmin:sudo apt-get purge phpmyadmin
Mysql配置文件:/etc/mysql/mysql.conf.d/myspls.cnf
mysql -u root -p
service mysql restart
ps ax
mysql_secure_installation