apache的配置
httpd.conf
缓存配置
<IfModule expires_module>
#打开缓存
ExpiresActive on
#css文件缓存7200000/3600/24=83天
ExpiresByType text/css A7200000
#js文件缓存7200000/3600/24=83天
ExpiresByType application/x-javascript A7200000
ExpiresByType application/javascript A7200000
#html文件缓存7200000/3600/24=83天
ExpiresByType text/html A7200000
#图片文件缓存7200000/3600/24=83天
ExpiresByType image/jpeg A7200000
ExpiresByType image/gif A7200000
ExpiresByType image/png A7200000
ExpiresByType image/x-icon A7200000
</IfModule>
httpd-vhosts.conf
<VirtualHost *:8080>
ServerAdmin webmaster@dummy-host.example.com
DocumentRoot "D:/***/***"
ServerName ny.***.com
ServerAlias ***.***.***.com
ErrorLog "logs/ny.***.com-error.log"
CustomLog "logs/ny.***.com-access.log" common
<Directory "D:/***/***">
Options Indexes MultiViews FollowSymLinks
Options MultiViews FollowSymLinks
# AllowOverride None
# Order allow,deny
# Allow from all
AllowOverride all
Require all granted
Header set Access-Control-Allow-Origin *
</Directory>
</VirtualHost>
<VirtualHost 127.0.0.2:8080>
ServerAdmin webmaster@dummy-host2.example.com
DocumentRoot "D:/***/***"
ServerName ***.qa.***.com
ErrorLog "logs/***.qa.***.com-error.log"
CustomLog "logs/***.qa.***.com-access.log" common
<Directory "D:/***/***">
AllowOverride all
Require all granted
</Directory>
</VirtualHost>
<VirtualHost 127.0.0.3:80>
ServerAdmin webmaster@dummy-host2.example.com
DocumentRoot "D:/***/***"
ServerName mid.qa.***.com
ErrorLog "logs/***.qa.***.com-error.log"
CustomLog "logs/***.qa.***.com-access.log" common
<Directory "D:/***/***">
AllowOverride all
Require all granted
</Directory>
</VirtualHost>
php项目根目录 .htaccess文件
<IfModule mod_rewrite.c>
RewriteEngine on
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_FILENAME} !-f
RewriteRule ^(.*)$ index.php/$1 [QSA,PT,L]
ExpiresActive on
ExpiresDefault "access plus 0 days"
ExpiresByType text/html "access"
ExpiresByType application/javascript "access plus 0 days"
ExpiresByType text/css "access plus 0 days"
ExpiresByType text/plain "access plus 1 years"
ExpiresByType image/gif "access plus 1 years"
ExpiresByType image/png "access plus 1 years"
ExpiresByType image/jpeg "access plus 1 years"
ExpiresByType image/x-icon "access plus 1 years"
FileETag Size
</IfModule>
nginx的配置
yum安装nginx启动方式
service nginx start
nginx.conf
/etc/nginx/nginx.conf
server {
listen 80 default_server;
listen [::]:80 default_server;
server_name www.***.cn;
# root /;
# Load configuration files for the default server block.
include /etc/nginx/default.d/*.conf;
location / {
proxy_pass http://localhost:8080;
}
error_page 404 /404.html;
location = /40x.html {
}
error_page 500 502 503 504 /50x.html;
location = /50x.html {
}
}
server {
listen 443 ssl http2 default_server;
listen [::]:443 ssl http2 default_server;
server_name www.***.cn;
# root /usr/local/***/src/main/resources/static
ssl_certificate "cert/3511353_www.***.cn.pem";
ssl_certificate_key "cert/3511353_www.***.cn.key";
ssl_session_cache shared:SSL:1m;
ssl_session_timeout 10m;
ssl_ciphers HIGH:!aNULL:!MD5;
ssl_prefer_server_ciphers on;
# # Load configuration files for the default server block.
include /etc/nginx/default.d/*.conf;
#
location / {
proxy_pass http://localhost:8080;
}
error_page 404 /404.html;
location = /40x.html {
}
error_page 500 502 503 504 /50x.html;
location = /50x.html {
}
}
static.conf
/etc/nginx/conf.d/static.conf 单独配置静态文件的目录
- 配置http,80端口
server {
listen 80;
server_name static.***.cn;
root /usr/local/***/src/main/resources/static/;
#location / {
# alias /usr/local/***/src/main/resources/static/;
#}
}
- 配置https,443端口 ; 需要配置证书.pem和.key
server {
listen 443;
server_name static.***.cn;
root /usr/local/***/src/main/resources/static/;
ssl_certificate "cert/3511392_static.***.cn.pem";
ssl_certificate_key "cert/3511392_static.***.cn.key";
ssl_session_cache shared:SSL:1m;
ssl_session_timeout 10m;
ssl_ciphers HIGH:!aNULL:!MD5;
ssl_prefer_server_ciphers on;
}
linux mysql
mysql遇到的自定义配置my.ini
default-character-set=utf8mb4
max_allowed_packet = 100M
wait_timeout = 120
yum安装mysql启动方式
service mysqld start
修改mysql数据库密码
update user set password=password('HBWaiyu11') where user='root' ;
flush privileges;
指定可以连接mysql数据库的服务器
GRANT ALL PRIVILEGES ON *.* TO 'root'@'%' WITH GRANT OPTION;
GRANT ALL PRIVILEGES ON *.* TO 'root'@'***' WITH GRANT OPTION;
用于重启java的shell文件restartJava.sh
#!/bin/sh
PID=$(ps -ef|grep java|awk '{if($0~/BookRental/) print $2}')
if [ $? -eq 0 ]; then
echo "process id:$PID"
else
echo "process java not exit"
exit
fi
kill -9 ${PID}
if [ $? -eq 0 ];then
echo "kill java success"
else
echo "kill java fail"
fi
echo 1 > /proc/sys/vm/drop_caches
echo 2 > /proc/sys/vm/drop_caches
echo 3 > /proc/sys/vm/drop_caches
rm -rf nohup.out
nohup java -Xms800m -Xmx800m -XX:+HeapDumpOnOutOfMemoryError -jar -Dserver.port=8080 /usr/local/BookRental/BookRental-0.0.1-SNAPSHOT.jar &
free -mh
linux服务器定时任务的配置
00 21 * * * curl https://www.***.cn/autoCancelOrder
00 10 * * * curl https://www.***.cn/autoManageOverTimeOrder
00 10 * * * curl https://www.***.cn/autoManageOverTimeCard
00 00 * * * curl https://www.***.cn/autoManageOverdueCard
*/60 * * * * curl https://www.***.cn/autoManageOverduePwdLock
*/20 * * * * curl https://www.***.cn/autoDelInvalidCardAndOrder
*/5 * * * * curl https://www.***.cn/autoDelCancelOrder
00 23 * * * sh /usr/local/***/database_bak.sh
00 05 * * * clamscan --no-summary --move=/usr/local/clamav -ri /
linux服务器配置java运行环境
#Java Env
export JAVA_HOME=/usr/local/jdk1.8.0_201
export CLASSPATH=.:$JAVA_HOME/lib/dt.jar:$JAVA_HOME/lib/tools.jar
export PATH=$PATH:$JAVA_HOME/bin