php default timezone & nginx fastcgi

This commit is contained in:
岳松
2016-09-02 10:19:11 +08:00
parent 33d62a2843
commit 0c27f0cf1e
4 changed files with 41 additions and 26 deletions

View File

@@ -1,22 +1,22 @@
server { server {
listen 80; listen 80;
server_name localhost; server_name localhost;
#charset koi8-r; #charset koi8-r;
#access_log /var/log/nginx/log/host.access.log main; #access_log /var/log/nginx/log/host.access.log main;
location / { location / {
root /usr/share/nginx/html; root /usr/share/nginx/html;
index index.php index.html index.htm; index index.php index.html index.htm;
} }
#error_page 404 /404.html; #error_page 404 /404.html;
# redirect server error pages to the static page /50x.html # redirect server error pages to the static page /50x.html
# #
error_page 500 502 503 504 /50x.html; error_page 500 502 503 504 /50x.html;
location = /50x.html { location = /50x.html {
root /usr/share/nginx/html; root /usr/share/nginx/html;
} }
# proxy the PHP scripts to Apache listening on 127.0.0.1:80 # proxy the PHP scripts to Apache listening on 127.0.0.1:80
@@ -28,17 +28,18 @@ server {
# pass the PHP scripts to FastCGI server listening on 127.0.0.1:9000 # pass the PHP scripts to FastCGI server listening on 127.0.0.1:9000
# #
location ~ \.php$ { location ~ \.php$ {
root /usr/share/nginx/html; root /usr/share/nginx/html;
fastcgi_pass 127.0.0.1:9000; try_files $uri =404;
fastcgi_index index.php; fastcgi_pass 127.0.0.1:9000;
fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name; fastcgi_index index.php;
include fastcgi_params; fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
include fastcgi_params;
} }
# deny access to .htaccess files, if Apache's document root # deny access to .htaccess files, if Apache's document root
# concurs with nginx's one # concurs with nginx's one
# #
#location ~ /\.ht { location ~ /\.(ht|svn|git) {
# deny all; deny all;
#} }
} }

23
lemp.sh
View File

@@ -53,7 +53,7 @@ sudo yum install -y nginx
# Install PHP # Install PHP
echo "Installing PHP..." echo "Installing PHP..."
sudo yum install -y --enablerepo=remi,remi-php70 php-gd php-fpm php-cli php-pdo php-xml php-json php-soap php-common php-mcrypt php-mysqlnd php-mbstring php-pecl-zip php-opcache sudo yum install -y --enablerepo=remi,remi-php70 php-gd php-fpm php-cli php-pdo php-xml php-json php-soap php-common php-mcrypt php-mysqlnd php-mbstring php-pecl-zip php-opcache php-xmlrpc
# Install Composer # Install Composer
echo "Installing Composer globally..." echo "Installing Composer globally..."
@@ -75,6 +75,7 @@ sudo sed -i 's/pdo_mysql.default_socket=/pdo_mysql.default_socket = \/var\/lib\/
sudo sed -i 's/mysqli.default_socket =/mysqli.default_socket = \/var\/lib\/mysql\/mysql.sock/g' /etc/php.ini sudo sed -i 's/mysqli.default_socket =/mysqli.default_socket = \/var\/lib\/mysql\/mysql.sock/g' /etc/php.ini
sudo sed -i 's/upload_max_filesize = 2M/upload_max_filesize = 20M/g' /etc/php.ini sudo sed -i 's/upload_max_filesize = 2M/upload_max_filesize = 20M/g' /etc/php.ini
sudo sed -i 's/post_max_size = 8M/post_max_size = 50M/g' /etc/php.ini sudo sed -i 's/post_max_size = 8M/post_max_size = 50M/g' /etc/php.ini
sudo sed -i 's/;date.timezone =/date.timezone = "Asia/Shanghai"/g' /etc/php.ini
sudo sed -i 's/user = apache/user = nginx/g' /etc/php-fpm.d/www.conf sudo sed -i 's/user = apache/user = nginx/g' /etc/php-fpm.d/www.conf
sudo sed -i 's/group = apache/group = nginx/g' /etc/php-fpm.d/www.conf sudo sed -i 's/group = apache/group = nginx/g' /etc/php-fpm.d/www.conf
@@ -85,9 +86,15 @@ sudo cp ./server.cnf /etc/my.cnf.d/server.cnf
# Restarting Services # Restarting Services
echo "Restarting Services..." echo "Restarting Services..."
sudo service mysql restart if [ "$CentOS_RHEL_version" == 6 ];then
sudo service php-fpm restart sudo service mysql restart
sudo service nginx restart sudo service php-fpm restart
sudo service nginx restart
else
sudo systemctl restart mariadb.service
sudo systemctl restart nginx.service
sudo systemctl restart php-fpm.service
fi
# Set Up Autostart # Set Up Autostart
echo "Setting Autostart..." echo "Setting Autostart..."
@@ -97,12 +104,12 @@ if [ "$CentOS_RHEL_version" == 6 ];then
sudo chkconfig --levels 235 nginx on sudo chkconfig --levels 235 nginx on
sudo chkconfig --levels 235 php-fpm on sudo chkconfig --levels 235 php-fpm on
else else
sudo systemctl enable mysql sudo systemctl enable mariadb.service
sudo systemctl enable nginx sudo systemctl enable nginx.service
sudo systemctl enable php-fpm sudo systemctl enable php-fpm.service
fi fi
# Done # Done
echo "Configuring MariaDB..." echo "Configuring MariaDB..."
sudo /usr/bin/mysql_secure_installation sudo mysql_secure_installation

View File

@@ -9,7 +9,7 @@ pid /var/run/nginx.pid;
events { events {
use epoll; use epoll;
worker_connections 51200; worker_connections 51200;
multi_accept on; multi_accept on;
} }
@@ -30,10 +30,17 @@ http {
client_max_body_size 50m; client_max_body_size 50m;
sendfile on; sendfile on;
tcp_nopush on; tcp_nopush on;
keepalive_timeout 120; keepalive_timeout 120s;
server_tokens off; server_tokens off;
tcp_nodelay on; tcp_nodelay on;
fastcgi_send_timeout 300s;
fastcgi_read_timeout 300s;
fastcgi_buffers 4 64k;
fastcgi_buffer_size 64k;
fastcgi_busy_buffers_size 128k;
fastcgi_temp_file_write_size 128k;
gzip on; gzip on;
gzip_vary on; gzip_vary on;
gzip_comp_level 6; gzip_comp_level 6;

View File

@@ -46,10 +46,10 @@ log_bin = mysql-bin
binlog_format = mixed binlog_format = mixed
expire_logs_days = 7 expire_logs_days = 7
log_error = /data/mariadb/mysql-error.log log_error = /var/lib/mysql/mysql-error.log
slow_query_log = 1 slow_query_log = 1
long_query_time = 1 long_query_time = 1
slow_query_log_file = /data/mariadb/mysql-slow.log slow_query_log_file = /var/lib/mysql/mysql-slow.log
performance_schema = 0 performance_schema = 0