Ubuntu 18.04 x64配置Nginx,Apache2,php7.2,mysql

下面代碼主要用於個人服務器備份,有感興趣不清楚的可以留言,不定期更新。

apt update

apt install nginx
ln -s /etc/nginx /var/www

apt install apache2
ln -s /etc/apache2 /var/www

apt install php
ln -s /etc/php /var/www

apt install mysql-server
apt install php7.2-mysql
ln -s /etc/mysql /var/www

mysql>mysql.conf.d>mysqld.conf
在[mysqld]後面添加character-set-server=utf8

apache2>ports.conf
修改Listen 8080

apache2>sites-enabled>000-default.conf
添加下面
<VirtualHost *:8080>;
  DocumentRoot /var/www/vue
</VirtualHost>

nginx>sites-enabled>default
添加下面
server {
  listen 80;
  server_name www.2shoushu.cn;
  
  location ^~ /api/ {
    proxy_pass http://127.0.0.1:8080;
    proxy_redirect     off;
    proxy_set_header   Host             $host;
    proxy_set_header   X-Real-IP        $remote_addr;
    proxy_set_header   X-Forwarded-For  $proxy_add_x_forwarded_for;
  }
  
  location / {
    root /var/www/vue;
    try_files $uri $uri/ /index.html;
  }
}

 

發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章