CentOS默認源里沒有nginx軟件 :wget http://www./installers/atomic sh ./atomic #安裝YUM源 yum check-update #更新yum軟件包 一、安裝nginx yum install nginx
service nginx start
chkconfig nginx on 二、安裝mysql yum install mysql mysql-server mysql-devel
service mysqld start
chkconfig mysqld on 三、安裝php #安裝PHP及組件,使PHP支持 MySQL、PHP支持FastCGI模式 yum install php php-mysql php-gd libjpeg* php-pear php-xml php-mbstring
php-mcrypt php-mhash libmcrypt libmcrypt-devel php-imap php-ldap php-odbc php-bcmath php-xmlrpc php-fpm
service mysqld restart
service nginx restart
service php-fpm start 四、配置nginx支持php vi /etc/nginx/nginx.conf #修改運行用戶
user nginx;
vi /etc/nginx/conf.d/default.conf #開啟php支持
index index.php index.html index.htm;
location ~ \.php$ {
root html; #取消FastCGI server部分location的注釋
fastcgi_pass 127.0.0.1:9000;
fastcgi_index index.php;
fastcgi_param SCRIPT_FILENAME /usr/share/nginx/html/$fastcgi_script_name; #$document_root設(shè)置為網(wǎng)站根目錄
include fastcgi_params;
} 1、配置php date.timezone = Asia/Shanghai #設(shè)置時區(qū)
expose_php = OFF #禁止顯示版本信息 2、配置php-fpm vi /etc/php-fpm.d/www.conf
user = nginx
group = nginx 3、測試 chown -R nginx.nginx /usr/share/nginx/html/ #設(shè)置目錄所有者
chmod 774 -R /usr/share/nginx/html/ #設(shè)置目錄權(quán)限
service mysqld restart
service nginx restart
service php-fpm restart
cd /usr/share/nginx/html/
vi index.php
<?Php phpinfo();?> http://127.0.0.1 #可以看到相關(guān)的配置信息! |
|
來自: 昵稱50041816 > 《待分類》