Fedora下nginx和php的安裝
1. nginx的安裝nginx安裝
wget https://github.com/nginx/nginx/archive/v1.7.11.zipunzip nginx-1.7.7.zip./configure --prefix=NGINX_INSTALL_PATHmake make -f objs/Makefile installnginx直接在objs下產生Makefile檔案.
nginx模組安裝
nginx模組和apache模組最大的區別在於其添加模組需要重新編譯檔案.下面展示下nginx-echo模組的安裝.
wget https://github.com/openresty/echo-nginx-module/archive/v0.57.zipmkdir $NGINX_INSTALL_PATH/modulesmv echo-nginx-module-0.57.zip $NGINX_INSTALL_PATH/modules && cd $NGINX_INSTALL_PATH/modulesunzip echo-nginx-module-0.57.zip cd $NGINX_INSTALL_PATH./configure --prefix=NGINX_INSTALL_PATH --add-module=$NGINX_INSTALL_PATH/modules/echo-nginx-module-0.5
2. mysql 安裝
mysql安裝可以直接到mysql官網下載repo檔案.
wget http://repo.mysql.com/mysql-community-release-fc21-6.noarch.rpmsudo yum install community-mysql-server.x86_64 mysql-workbench-community.x86_64
3. php安裝
這裡主要用到php-fpm來負責執行php檔案,在php核心5.3.3以上,php源碼內建php-fpm
wget -c http://cn2.php.net/distributions/php-5.6.9.tar.gz(由於php檔案較大,最好開啟斷點續傳)./configure --prefix=/usr/local/php-5.6.9 --enable-fpm --with-mysqlmake && make installsudo ln -s /usr/local/php-5.6.9 /usr/local/php
這樣我們就安裝好php,然後運行php-fpm,不過在這之前,需要將
cp /usr/local/php/etc/php-fpm.conf.default /usr/local/etc/php-fpm.conf
我們現在就用裡面的預設配置,然後到sbin目錄下開啟php-fpm服務.
sudo sbin/php-fpm
4. nginx下配置php
location ~* \.php$ { fastcgi_pass 127.0.0.1:9000; fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name; fastcgi_param PATH_INFO $fastcgi_script_name; include fastcgi_params; }
現在start nginx
在html目錄添加index.php檔案.
訪問http://localhost/index.php
出現
這樣nginx和php的安裝配置就完成了.