1. 程式人生 > >ubantu下安裝配置 nginx,mysql, php可能遇到的問題及對策

ubantu下安裝配置 nginx,mysql, php可能遇到的問題及對策

安裝nginx

nginx歷史版本下載(1.4.2):

http://nginx.org/download/

1,安裝:zlib1g-dev

apt-get install zlib1g-dev

2,安裝pcre : 

apt-get install libpcre3 libpcre3-dev

3,安裝nginx:

./configure --prefix=/usr/local/nginx

make && make install


安裝mysql

apt-get install mysql-sever mysql-client libmysqlclient-dev

安裝php

php歷史版本下載(5.4.19):

http://www.php.net/releases/

1,安裝libxml2

apt-get install libxml2 libxml2-dev

2,安裝libpng

apt-get install libpng12-dev

3,安裝php

./configure  --prefix=/usr/local/php \

--with-mysql=mysqlnd \

--enable-mysqlnd \

--with-gd \

--enable-gd-native-ttf \

--enable-gd-jis-conv \

--enable-fpm

4,拷貝配置檔案

cp /usr/local/src/php-5.4.19/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

5,啟動php

groupadd nobody

./sbin/php-fpm

gedit /usr/local/nginx/conf/nginx.conf

第一處

server {
        listen       80;
        server_name  localhost;
        root   html;

第二處 

location ~ \.php$ {

            root           html;
            fastcgi_pass   127.0.0.1:9000;
            fastcgi_index  index.php;
            #fastcgi_param  SCRIPT_FILENAME  /scripts$fastcgi_script_name;
            fastcgi_param  SCRIPT_FILENAME  /usr/local/nginx/html
/$fastcgi_script_name;
            include        fastcgi_params;

        }

/usr/local/nginx/html/test.php內容如下

<?php

phpinfo();

瀏覽器輸入127.0.0.1/test.php

mysql測試

mysql -u root –p

如果提示ERROR 1045 (28000): Access denied for user 'root'@'localhost' (using password: NO):

/etc/init.d/mysql stop

/etc/init.d/mysql restart

啟動、停止、重啟mysql服務的方法:

service mysql start/stop/restart

或/etc/init.d/mysql start(stop、restart)

centos下需要把上述mysql換為mysqld