nginx/1.18安装
-
安装nginx
# 更新apt仓库缓存 sudo apt-get update # 安装nginx sudo apt-get install nginx # 检查状态 sudo systemctl status nginx
-
配置nginx
查找配置文件:
sudo find / -name nginx.conf sudo vim /etc/nginx/nginx.conf
配置nginx.conf更改:
# 客户端上传文件大小 client_max_body_size 20m; # 设置网站访问验证 auth_basic "Please input user and password"; # 验证时的提示信息 auth_basic_user_file .htpasswd; # 认证文件
配置default更改:
server { listen 80 default_server; listen [::]:80 default_server; # SSL configuration # # listen 443 ssl default_server; # listen [::]:443 ssl default_server; # # Note: You should disable gzip for SSL traffic. # See: https://bugs.debian.org/773332 # # Read up on ssl_ciphers to ensure a secure configuration. # See: https://bugs.debian.org/765782 # # Self signed certs generated by the ssl-cert package # Don't use them in a production server! # # include snippets/snakeoil.conf; root /var/www/html; # Add index.php to the list if you are using PHP index index.html index.htm index.nginx-debian.html; server_name example.com; ssl on; ssl_certificate cert/example.com.pem; ssl_certificate_key cert/example.com.key; ssl_session_timeout 5m; ssl_ciphers ECDHE-RSA-AES128-GCM-SHA256:ECDHE:ECDH:AES:HIGH:!NULL:!aNULL:!MD5:!ADH:!RC4; ssl_protocols TLSv1 TLSv1.1 TLSv1.2; ssl_prefer_server_ciphers on; #location / { # First attempt to serve request as file, then # as directory, then fall back to displaying a 404. # try_files $uri $uri/ =404; #} # testCiProject location /testCiProject/api/ { try_files $uri $uri/ /testCiProject/api/index.php?/$request_uri; } # pass PHP scripts to FastCGI server # location ~ \.php$ { include snippets/fastcgi-php.conf; # # # With php-fpm (or other unix sockets): fastcgi_pass unix:/var/run/php/php5.6-fpm.sock; # # With php-cgi (or other tcp sockets): # fastcgi_pass 127.0.0.1:9000; } # deny access to .htaccess files, if Apache's document root # concurs with nginx's one # #location ~ /\.ht { # deny all; #} }
PHP/5.6安装
-
安装php
# 更新安装源 sudo add-apt-repository ppa:ondrej/php # 更新apt仓库缓存 sudo apt-get update # 查询当前仓库的php版本 sudo apt-cache show php5.6 # 安装php5.6 sudo apt-get install php5.6 # 安装php5.6拓展 sudo apt-get install php5.6-mcrypt php5.6-mbstring php5.6-curl php5.6-cli php5.6-mysql php5.6-gd php5.6-intl php5.6-xsl php5.6-zip # 安装php5.6-fpm sudo apt-get install php5.6-fpm # 检查状态 sudo systemctl status php5.6-fpm
-
安装PHP代码解密扩展
# 将ioncube.tar.gz解压到home目录,执行以下操作 sudo tar -zxvf ioncube.tar.gz sudo mv ~/ioncube/ioncube_loader_lin_5.6.so /usr/lib/php/20131226/ sudo mv ~/ioncube/00-ioncube.ini /etc/php/5.6/fpm/conf.d
-
配置php.ini文件
查找配置文件:
sudo find / -name php.ini sudo vim /etc/php/5.6/fpm/php.ini
配置更改:
# 允许上传文件大小的最大值 upload_max_filesize = 20M # 通过表单POST给PHP的所能接收的最大值 post_max_size = 30M # php页面占用的最大内存 memory_limit = 256M # php页面执行最大时间 max_execution_time = 300 # php页面接受数据最大时间 max_input_time = 600
-
卸载apach(防止跟nginx端口冲突,可不操作)
sudo apt-get --purge remove apache2 sudo apt-get --purge remove apache2.2-common sudo apt-get autoremove sudo find /etc -name "*apache*" -exec rm -rf {} \;
mysql/5.7安装
-
安装mysql
# 获得deb包 wget https://dev.mysql.com/get/mysql-apt-config_0.8.12-1_all.deb # 安装deb包(中间选择5.7) sudo dpkg -i mysql-apt-config_0.8.12-1_all.deb # 更新apt仓库缓存 sudo apt-get update # 如果更新报错,缺少key,则运行下列语句,替换对应缺少的key sudo apt-key adv --keyserver keyserver.ubuntu.com --recv-keys 467B942D3A79BD29 # 更新后查看当前mysql的可安装版本 sudo apt-cache policy mysql-server # 安装 mysql5.7(安装过程需要配置输入 mysql root 的password) sudo apt install -f mysql-client=5.7* mysql-community-server=5.7* mysql-server=5.7* # 如果报错,先取消上面的安装 sudo apt --fix-broken install # 然后安装对应的依赖 # 安装libmecab2 sudo apt install libmecab2 # 安装libaio1 sudo apt install libaio1 # 安装mysql-community-client sudo apt install mysql-community-client=5.7* # 再次安装 mysql 5.7 sudo apt install -f mysql-client=5.7* mysql-community-server=5.7* mysql-server=5.7*
-
配置mysql
查找配置文件:
sudo find / -name my.cnf sudo vim /etc/mysql/mysql.conf.d/mysqld.cnf
配置更改:
# 允许远程配置 bind-address = 0.0.0.0 # 在【mysqld】下加入以下配置(解决group by报错解决) sql_mode=STRICT_TRANS_TABLES,NO_ZERO_IN_DATE,NO_ZERO_DATE,ERROR_FOR_DIVISION_BY_ZERO,NO_AUTO_CREATE_USER,NO_ENGINE_SUBSTITUTION group_concat_max_len = 102400
-
创建数据库
create database zhky default character set utf8 collate utf8_general_ci;
更改文件权限
# 修改权限 文件夹 755
sudo find zhky -type d -exec chmod 755 {} \;
# 用户改root权限
sudo chown root:root -R zhky
# 修改文件权限 644
sudo find zhky -type f -exec chmod 644 {} \;
# 修改uploads文件夹权限
sudo chown www-data:www-data -R uploads/