linux 安裝php+nginx+mysql

1、下載安裝包;
[url]http://www.unix-pub.net/install.tar[/url]

2、上傳到服務器,解壓(tar zxvf )安裝包到/usr/local/src目錄下,進入目錄,執行
sh install.sh文件,等待一段時間(一般需要半小時以上);

3、mysql配置管理
(1)運行/usr/local/mysql/share/mysql/mysql.server start 啓動mysql;
使用/usr/local/mysql/bin/mysqladmin -u root password 123456設置密碼;
使用/usr/local/mysql/bin/mysql -u root -p,輸入123456操作;

(2)以上測試mysql各個操作沒問題,接下來設置遠程機器訪問本數據庫
防火牆打開3306端口步驟:
設定:/sbin/iptables -I INPUT -p tcp --dport 3306 -j ACCEPT
保存:/etc/rc.d/init.d/iptables save
重啓防火牆服務:service iptables restart
查看開啓端口:/etc/init.d/iptables status

(3)修改密碼:
mysql> UPDATE mysql.user SET password=PASSWORD(’新密碼’) WHERE User=’root’;
mysql> FLUSH PRIVILEGES;
PS:(1)遠程使用root連接如出現10060錯誤,一般都是防火牆沒有打開端口,另一個可能用戶沒授權,mysql授權表裏沒有遠程機器的權限,及需要在授權表mysql.user添加
#grant all privileges on *.* to 'root'@'遠程登陸IP' identified by '遠程登陸密碼'
#flush privileges;
(2)如出現 Access denied for user ''@'localhost' to database 'mysql'錯誤
見:[url]http://blog.csdn.net/tys1986blueboy/article/details/7056835[/url]
(3)Can't open the mysql.plugin table. Please run mysql_upgrade to create it.
執行:scripts/mysql_install_db --user=root --datadir=/usr/local/mysql/var

4、PHP配置管理
下載php5.2.17安裝包
執行
./configure --prefix=/usr/local/php --with-iconv-dir=/usr/local --with-freetype-dir --with-jpeg-dir --with-png-dir --with-zlib --with-libxml-dir=/usr --enable-xml --disable-rpath --enable-discard-path --enable-safe-mode --enable-bcmath --enable-shmop --enable-sysvsem --enable-inline-optimization --with-curl --with-curlwrappers --enable-mbregex --enable-fastcgi --enable-fpm --enable-force-cgi-redirect 
32
--enable-mbstring --with-mcrypt --with-gd --enable-gd-native-ttf --with-openssl --with-mhash --enable-pcntl --enable-sockets --with-ldap --with-ldap-sasl --with-xmlrpc --enable-zip --enable-soap --without-pear


再執行make & make install

PS:make時候報錯:
ext/gd/libgd/gdkanji.c:350: undefined reference to `libiconv_open
錯誤,執行vim Makefile 找到EXTRA_LIBS 加上 -liconv

#cp php.ini-dist /usr/local/php/etc/php.ini
啓動PHP-FPM:#/usr/local/php/sbin/php-fpm start
可能會報用戶和組相關的錯誤,編輯:#vi /usr/local/php/etc/php-fpm.conf
找到<value name="user">、<value name="group">標籤,修改值爲nobody;然後再啓動;

5、nginx配置管理
nginx默認不安裝的,需要進入安裝/usr/local/src/nginx-0.6.36/,運行#./configure;
具體的linux的詳細安裝見:[url]http://itsoul.iteye.com/blog/792201[/url]

6、php+nginx整合
打開/usr/local/nginx/conf/nginx.conf文件,找到
location ~ \.php$ {
#root html;
fastcgi_pass 127.0.0.1:9000;
fastcgi_index index.php;
fastcgi_param SCRIPT_FILENAME /var/www/html$fastcgi_script_name;
include fastcgi_params;
}

把這些代碼給註釋開,/var/www/html是你存放php代碼的地方;
重啓nginx,訪問http://localhost/index.php,一切OK。

7、遠程訪問該地址
如果防火牆80端口沒有打開,需要設置下防火牆文件
編輯文件:#vi /etc/sysconfig/iptables
添加行:-A RH-Firewall-1-INPUT -p tcp -m tcp --dport 80 -j ACCEPT,保存退出。
重啓服務:#service iptables restart
發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章