部署php的正确姿势

1、 更新源

apt-get update

2、安装apache

apt-get install apache2

ubuntu下apache2虚拟主机配置

  

cd /etc/apache2/sites-available
ls
000-default.conf  default-ssl.conf
sudo cp 000-default.conf 000-default.conf.bak
sudo vim 000-default.conf

  文件修改为以下内容

// 此处由于下边要把apache端口设为8080 也要改为8080端口
<VirtualHost *:8080>
  
    ServerAdmin webmaster@localhost
    DocumentRoot /data/www
  
    ErrorLog ${APACHE_LOG_DIR}/error.log
    CustomLog ${APACHE_LOG_DIR}/access.log combined
  
    <Directory />
        Options Indexes FollowSymLinks
        AllowOverride None
        Require all granted
    </Directory>
  
</VirtualHost>

3、安装php7.0

apt-get install php7.0

4、安装mysql  https://www.cnblogs.com/Mvloveyouforever/p/9931290.html

5、安装nginx

apt-get install nginx

    ①配置nginx 

  • 修改/etc/nginx/sites-available/default

     

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;
                proxy_pass http://127.0.0.1:8080; # 添加此代码,指向动态服务器的ip地址及端口号
        }

    ②配置apache

  • 修改监听的端口号/etc/apache2/ports.conf
# Listen 80
Listen 8080

   ③重启服务

/etc/init.d/nginx reload
/etc/init.d/apache2 reload

  至此: 带php后缀的 80端口 直接指向apache,其他从nginx配置走。

猜你喜欢

转载自www.cnblogs.com/Mvloveyouforever/p/10242196.html