Nginx依賴的包不多,除了常規的編譯包,再安裝上一下幾個開發包就可以了。
sudo yum install pcre-devel zlib-devel openssl-devel
makesudo make installnginx默認安裝到/usr/local/nginx路徑。2.安裝PHP運行環境
sudo yum install php-devel php-fpm php-mysql php-pdo
運行PHP-FPM
sudo php-fpm -D3.安裝PHP的mcrypt擴展CentOS 7運行Laravel的一個不方便的地方就是yum沒有php的mcrypt擴展,需要手動編譯安裝一個。 首先需要編譯安裝libmcrypt。
tar zxvf libmcrypt-2.5.8.tar.gzcd libmcrypt-2.5.8./configuremakesudo make install
; Enable mcrypt extension moduleextension=mcrypt.so
#user nobody;worker_processes 8;#error_log logs/error.log;#error_log logs/error.log notice;#error_log logs/error.log info;#pid logs/nginx.pid;events { worker_connections 1024;}http { include mime.types; default_type application/octet-stream; #log_format main '$remote_addr - $remote_user [$time_local] "$request" ' # '$status $body_bytes_sent "$http_referer" ' # '"$http_user_agent" "$http_x_forwarded_for"'; #access_log logs/access.log main; sendfile on; #tcp_nopush on; #keepalive_timeout 0; keepalive_timeout 65; client_max_body_size 100m; gzip on; server { listen 80; server_name localhost; set $root_path '/srv/www/default/html' target='_blank'>public'; root $root_path; index index.php index.html index.htm; try_files $uri $uri/ @rewrite; location @rewrite { rewrite ^/(.*)$ /index.php?_url=/$1; } location ~ .php { fastcgi_pass 127.0.0.1:9000; fastcgi_index /index.php; include /usr/local/nginx/conf/fastcgi_params; fastcgi_split_path_info ^(.+.php)(/.+)$; fastcgi_param PATH_INFO $fastcgi_path_info; fastcgi_param PATH_TRANSLATED $document_root$fastcgi_path_info; fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name; } location ~* ^/(css|img|js|flv|swf|download)/(.+)$ { root $root_path; } location ~ /.ht { deny all; } } # another virtual host using mix of IP-, name-, and port-based configuration # #server { # listen 8000; # listen somename:8080; # server_name somename alias another.alias; # location / { # root html; # index index.html index.htm; # } #} # HTTPS server # #server { # listen 443 ssl; # server_name localhost; # ssl_certificate cert.pem; # ssl_certificate_key cert.key; # ssl_session_cache shared:SSL:1m; # ssl_session_timeout 5m; # ssl_ciphers HIGH:!aNULL:!MD5; # ssl_prefer_server_ciphers on; # location / { # root html; # index index.html index.htm; # } #}}由于PHP-FPM使用apache用戶運行,所以修改網站根目錄的權限給apache用戶。
cd /srv/wwwchown -R apache defaultchgrp -R apache default
sudo /usr/local/nginx/sbin -s reload
鄭重聲明:本文版權歸原作者所有,轉載文章僅為傳播更多信息之目的,如作者信息標記有誤,請第一時間聯系我們修改或刪除,多謝。
新聞熱點
疑難解答
圖片精選