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 {
listen 80;
server_name localhost;
listen 80;
server_name localhost;
#charset koi8-r;
#access_log /var/log/nginx/log/host.access.log main;
location / {
root /usr/share/nginx/html;
index index.php index.html index.htm;
root /usr/share/nginx/html;
index index.php index.html index.htm;
}
#error_page 404 /404.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 {
root /usr/share/nginx/html;
root /usr/share/nginx/html;
}
# 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
#
location ~ \.php$ {
root /usr/share/nginx/html;
fastcgi_pass 127.0.0.1:9000;
fastcgi_index index.php;
fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
include fastcgi_params;
root /usr/share/nginx/html;
try_files $uri =404;
fastcgi_pass 127.0.0.1:9000;
fastcgi_index index.php;
fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
include fastcgi_params;
}
# deny access to .htaccess files, if Apache's document root
# concurs with nginx's one
#
#location ~ /\.ht {
# deny all;
#}
location ~ /\.(ht|svn|git) {
deny all;
}
}

23
lemp.sh
View File

@@ -53,7 +53,7 @@ sudo yum install -y nginx
# Install 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
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/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/;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/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
echo "Restarting Services..."
sudo service mysql restart
sudo service php-fpm restart
sudo service nginx restart
if [ "$CentOS_RHEL_version" == 6 ];then
sudo service mysql 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
echo "Setting Autostart..."
@@ -97,12 +104,12 @@ if [ "$CentOS_RHEL_version" == 6 ];then
sudo chkconfig --levels 235 nginx on
sudo chkconfig --levels 235 php-fpm on
else
sudo systemctl enable mysql
sudo systemctl enable nginx
sudo systemctl enable php-fpm
sudo systemctl enable mariadb.service
sudo systemctl enable nginx.service
sudo systemctl enable php-fpm.service
fi
# Done
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 {
use epoll;
worker_connections 51200;
worker_connections 51200;
multi_accept on;
}
@@ -30,10 +30,17 @@ http {
client_max_body_size 50m;
sendfile on;
tcp_nopush on;
keepalive_timeout 120;
keepalive_timeout 120s;
server_tokens off;
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_vary on;
gzip_comp_level 6;

View File

@@ -46,10 +46,10 @@ log_bin = mysql-bin
binlog_format = mixed
expire_logs_days = 7
log_error = /data/mariadb/mysql-error.log
log_error = /var/lib/mysql/mysql-error.log
slow_query_log = 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