nginx mysql php安裝配置的方法:1、下載Nginx並安裝啟動nginx;2、解壓縮「php-7.2.25.tar.gz」並安裝php所需的依賴;3、更改nginx的設定檔;4、安裝mysql並啟動服務即可。
本文操作環境:centos7系統、php 7.2.25版、DELL G3電腦
nginx mysql php如何安裝設定?
CentOS7 下nginx與PHP mysql的安裝與設定:
下載Nginx
首先安裝的依賴套件:
gcc automake autoconf libtool make gcc gcc-c openssl openssl-devel
/zlib-1.2.11.tar.gz
wget http://downloads.sourceforge.net/project/pcre/pcre/8.35/pcre-8.35.tar.gz
# 1.在伺服器上新建資料夾 /home/soft/ ;
2.cd /home/soft/ => 執行指令下載Nginx /download/nginx-1.7.4.tar.gz ; 》 皮 》.問題 》.問題 皮. .tar.gz3.解壓縮下載後的壓縮包到/opt/software/ => tar -zvxf nginx-1.7.4.tar.gz -C /opt/software/ ;
## 4.cd/; opt/software/nginx-1.7.4/ => ./configure --prefix=/usr/local/nginx/ ; 5.make && make install ;## 5.make && make install ;## 6.啟動nginx => /usr/
local/nginx/sbin/nginx 7.開啟瀏覽器存取此機器的IP,如果瀏覽器出現Welcome to nginx! 則表示Nginx 已經安裝並運行成功。
測試設定檔是否正常:/usr/local/nginx/sbin/nginx –t
強制關閉:pkill nginx## 下載php
2.解壓縮php-7.2.25.tar.gz => tar -zvxf php-7.2.25.tar.gz -C /opt/software/ ;
3. cd /opt/software/ ;
3. cd /opt/software/php7. .25/;
4. 先安裝php所需的依賴:yum update yum -y install libjpeg libjpeg-devel libpng libpng-devel freetype freetype-devel libxml2 libxml2-devel MySQL pcre-devel yum -y install curl-devel yum -y install libxslt-devel yum install openssl openssl-devel
./configure --prefix=/usr/local/php --with-curl --with-freetype-dir --with-gd --with-gettext --with-iconv-dir --with-kerberos --with-libdir=lib64 --with-libxml-dir --with-mysqli --with-openssl --with-pcre-regex --with-pdo-mysql --with-pdo-sqlite --with-pear --with-png-dir --with-xmlrpc --with-xsl --with-zlib --enable-fpm --enable-bcmath --enable-libxml --enable-inline-optimization --enable-gd-native-ttf --enable-mbregex --enable-mbstring --enable-opcache --enable-pcntl --enable-shmop --enable-soap --enable-sockets --enable-sysvsem --enable-xml --enable-zip
cp /opt/software/php-7.2.25/php.ini-development /usr/local/php/lib/php.ini cp /usr/local/php/etc/php-fpm.conf.default /usr/local/php/etc/php-fpm.conf cp /usr/local/php/etc/php-fpm.d/www.conf.default /usr/local/php/etc/php-fpm.d/www.conf cp -R /opt/software/php-7.2.25/sapi/fpm/php-fpm /etc/init.d/php-fpm * 需要注意的是php7中www.conf这个配置文件配置phpfpm的端口号等信息,如果你修改默认的9000端口号需在这里改,再改nginx的配置
Ngin解析php:
# 1.更改nginx的設定檔 => vim /usr/local/nginx/etc/nginx/ nginx.conf###location ~ \.php$ { root /usr/share/nginx/html; #指定php的根目录 fastcgi_pass 127.0.0.1:9000; #php-fpm的默认端口是9000 fastcgi_index index.php; fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name; #路径 include fastcgi_params; }
vim /usr/lib/systemd/system/php-fpm.service [Unit] Description=php After=network.target [Service] Type=forking ExecStart=/usr/local/php/sbin/php-fpm ExecStop=/bin/pkill -9 php-fpm PrivateTmp=true [Install] WantedBy=multi-user.target
systemctl restart php-fpm.service systemctl enable php-fpm.service
開啟遠端連線
在 MySQL 中輸入 GRANT ALL PRIVILEGES ON *.* TO 'username'@'%' IDENTIFIED BY 'password' WITH GRANT OPTION; 。新增完成後在開啟連接埠
推薦學習:《PHP影片教學》
以上是nginx mysql php如何安裝配置的詳細內容。更多資訊請關注PHP中文網其他相關文章!