咱們已經裝好了nginx,如今咱們開始裝mysql和phpphp
咱們一樣使用yum來安裝。html
先安裝MySQL軟件(客戶端、服務器端、依賴庫)mysql
yum install -y mysql mysql-server mysql-devel
而後設置自啓動,報錯nginx
正確的安裝方法以及錯誤緣由參考這裏laravel
好了,到這裏咱們就安裝好mysql了,下面咱們開始安裝php。web
詳細安裝參考個人另外一篇文章:Centos 6/ 7下經過yum安裝php7環境sql
也能夠參考另一篇文章:yum安裝新版php7.0 後來更新了,也能夠安裝7.2了vim
總結一下,首先是更新yum源,根據本身的CentOS版原本選擇centos
CentOS/RHEL 7.x:服務器
rpm -Uvh https://dl.fedoraproject.org/pub/epel/epel-release-latest-7.noarch.rpm rpm -Uvh https://mirror.webtatic.com/yum/el7/webtatic-release.rpm
若是是centos6,那麼執行如下代碼:
CentOS/RHEL 6.x:
rpm -Uvh https://dl.fedoraproject.org/pub/epel/epel-release-latest-6.noarch.rpm rpm -Uvh https://mirror.webtatic.com/yum/el6/latest.rpm
而後就能夠yum安裝PHP了
yum install php70w-common
要安裝其餘拓展的話上面文章裏有,這裏我已經安裝好了laravel5.5所需的拓展了
//使用命令查看拓展 php -m
而後,咱們配置一下nginx
vim /etc/nginx/nginx.conf
#這一段是最原始的配置,咱們註釋掉 # server { # listen 80 default_server; # listen [::]:80 default_server; # server_name _; # root /usr/share/nginx/html; # # # Load configuration files for the default server block. # include /etc/nginx/default.d/*.conf; # # location / { # } # # error_page 404 /404.html; # location = /40x.html { # } # # error_page 500 502 503 504 /50x.html; # location = /50x.html { # } # } #寫入咱們新的配置
server { listen 80;# 監聽端口 server_name localhost;# 站點域名 #charset koi8-r; #access_log logs/host.access.log main; root /home/wwwroot/blog/public/;# 站點根目錄 location / { index index.html index.htm index.php l.php;# 默認導航頁 autoindex off; try_files $uri $uri/ /index.php?$query_string; } #error_page 404 /404.html; # redirect server error pages to the static page /50x.html # error_page 500 502 503 504 /50x.html; location = /50x.html { root html; } # proxy the PHP scripts to Apache listening on 127.0.0.1:80 # #location ~ \.php$ { # proxy_pass http://127.0.0.1; #} # pass the PHP scripts to FastCGI server listening on 127.0.0.1:9000 # location ~ \.php(.*)$ { fastcgi_pass 127.0.0.1:9000; fastcgi_index index.php; fastcgi_split_path_info ^((?U).+\.php)(/?.+)$; fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name; fastcgi_param PATH_INFO $fastcgi_path_info; fastcgi_param PATH_TRANSLATED $document_root$fastcgi_path_info; include fastcgi_params; } # deny access to .htaccess files, if Apache's document root # concurs with nginx's one # #location ~ /\.ht { # deny all; #} }
而後重啓nginx
service nginx restart
訪問一下,能夠了!(這裏我提早在站點目錄裏寫了一個php文件,沒有寫的能夠寫一個)
好的,至此環境就搭好了,下一篇咱們準備安裝larvael了,不太會寫,有什麼不對的地方還請你們留言指出,共同窗習!