【安裝Nginx】 #先安裝以下包 yum install gcc gcc-c++ kernel-devel yum -y install pcre-devel openssl openssl-devel #解壓nginx-1.12.0.tar.gz 而後進入目錄 ./configure --prefix=/usr/local/nginx --with-http_stub_status_module make && make install 【安裝MySQL】 #先安裝以下包: yum -y install make gcc-c++ cmake bison-devel ncurses-devel #解壓mysql-5.6.14.tar.gz 而後進入目錄 cmake -DCMAKE_INSTALL_PREFIX=/usr/local/mysql -DMYSQL_DATADIR=/usr/local/mysql/data -DSYSCONFDIR=/etc -DWITH_MYISAM_STORAGE_ENGINE=1 -DWITH_INNOBASE_STORAGE_ENGINE=1 -DWITH_MEMORY_STORAGE_ENGINE=1 -DWITH_READLINE=1 -DMYSQL_UNIX_ADDR=/var/lib/mysql/mysql.sock -DMYSQL_TCP_PORT=3306 -DENABLED_LOCAL_INFILE=1 -DWITH_PARTITION_STORAGE_ENGINE=1 -DEXTRA_CHARSETS=all -DDEFAULT_CHARSET=utf8 -DDEFAULT_COLLATION=utf8_general_ci make && make install 【安裝PHP】 #先安裝以下包: yum install -y gcc gcc-c++ make zlib zlib-devel pcre pcre-devel libjpeg libjpeg-devel libpng libpng-devel freetype freetype-devel libxml2 libxml2-devel glibc glibc-devel glib2 glib2-devel bzip2 bzip2-devel ncurses ncurses-devel curl curl-devel e2fsprogs e2fsprogs-devel krb5 krb5-devel openssl openssl-devel openldap openldap-devel nss_ldap openldap-clients openldap-servers #解壓php-7.1.6.tar.gz 而後進入目錄 ./configure --prefix=/usr/local/php --with-config-file-path=/usr/local/php --enable-mbstring --enable-ftp --with-gd --with-jpeg-dir=/usr --with-png-dir=/usr --with-mysql=mysqlnd --with-mysqli=mysqlnd --with-pdo-mysql=mysqlnd --with-pear --enable-sockets --with-freetype-dir=/usr --enable-gd-native-ttf --with-zlib --with-libxml-dir=/usr --with-xmlrpc --enable-zip --enable-fpm --enable-xml --enable-sockets --with-gd --with-zlib --with-iconv --enable-zip --with-freetype-dir=/usr/lib/ --enable-soap --enable-pcntl --enable-cli --with-curl make && make install
$ /usr/local/server/nginx/sbin/nginx #啓動Nginx $ /usr/local/server/nginx/sbin/nginx -s stop #斷開Nginx $ /usr/local/server/nginx/sbin/nginx -s reload #重啓Nginx $ ps -ef | grep nginx 或者 ps -A | grep -i nginx #查看是否成功啓動nginx
(1)index index.html index.htm; 改成: index index.html index.htm index.php; (2)#location ~ \.php$ { # root html; # fastcgi_pass 127.0.0.1:9000; # fastcgi_index index.php; # fastcgi_param SCRIPT_FILENAME /scripts$fastcgi_script_name; # include fastcgi_params; #} 改成: location ~ \.php$ { # root html; fastcgi_pass 127.0.0.1:9000; fastcgi_index index.php; fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name; include fastcgi_params; }
http { include mime.types; default_type application/octet-stream; #------ 開啓Nginx的目錄文件列表功能 -----# autoindex on; #自動顯示目錄 autoindex_exact_size off; #人性化方式顯示文件大小不然以byte顯示 autoindex_localtime on; #按服務器時間顯示,不然以gmt時間顯示 ... }
server { listen 80; server_name centos.a.com; root /usr/local/nginx/html/test; charset utf-8; # access_log /logs/admin_access.log; # error_log /logs/admin_error.log; index index.php index.html; location ~ \.php$ { fastcgi_pass 127.0.0.1:9000; fastcgi_index index.php; fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name; include fastcgi_params; } } 而後在 /etc/hosts 中添加: 127.0.0.1 centos.a.com
location /qgzs_apiv2/app/ { index index.php; if (!-e $request_filename) { rewrite ^/qgzs_apiv2/app/(.*)$/qgzs_apiv2/app/index.php/$1 last; break; } } location ~ .+\.php($|/) { set $script $uri; set $path_info "/"; if ($uri ~ "^(.+\.php)(/.+)") { set $script $1; set $path_info $2; } fastcgi_pass 127.0.0.1:9000; fastcgi_index index.php?IF_REWRITE=1; include fastcgi_params; fastcgi_param PATH_INFO $path_info; fastcgi_param SCRIPT_FILENAME $document_root/$script; fastcgi_param SCRIPT_NAME $script; }
display_errors = On
$ cd /usr/local/php/etc $ cp php-fpm.conf.default php-fpm.conf 而後,vim php-fpm.conf 編輯配置文件: ① 去掉 pid = run/php-fpm.pid 前面的分號 ② 修改user和group的用戶爲當前用戶 ③ pm.max_children = 50 pm.start_servers = 20 pm.min_spare_servers = 5 pm.max_spare_servers = 35