sudo apt-get install nginx
sudo apt-get install php7.0-fpm
sudo apt-get install php7.0-curl
sudo apt-get install php7.0-gd php7.0-mcrypt php7.0-mysql
sudo apt-get install mysql-server mysql-client
Please remember your mysql database root password!!!
Let's config up.
1. Add nginx user and group, nginx server and php-fpm will run as nginx user.
sudo groupadd nginxsudo groupadd nginx
sudo useradd -g nginx nginx
sudo service php7.0-fpm restart
2. Config php-fpm
/etc/php/7.0/fpm/php.ini
cgi.fix_pathinfo=0
/etc/php/7.0/fpm/pool.d/www.conf
listen = /run/php/php7.0-fpm.sock
listen.owner = nginx
listen.group = nginx
sudo service php7.0-fpm restart
3. Config nginx
/etc/nginx/nginx.conf
user nginx nginx;
location ~ \.php$ {
include fastcgi.conf;
fastcgi_pass unix:/run/php/php7.0-fpm.sock;
}
sudo service nginx restart
PS:keep the user/group of php-fpm same as nginx server, I have marked as blue nginx above.
My websites are in vhosts folder, the user/group are errong_leng.
drwxrwxr-x 4 errong_leng errong_leng 4096 May 19 09:11 vhosts
Ok. let's do the test.
cat index.php
<?php
phpinfo();
?>
Everything looks fine.
cat index.php <?php phpinfo(); ?>
drwxrwxr-x 4 errong_leng errong_leng 4096 May 19 09:11 vhosts
drwxrwxr-x 4 errong_leng errong_leng 4096 May 19 09:11 vhosts
drwxrwxr-x 4 errong_leng errong_leng 4096 May 19 09:11 vhosts
drwxrwxr-x 4 errong_leng errong_leng 4096 May 19 09:11 vhosts
No comments:
Post a Comment