http://www.cnblogs.com/whoamme/
Centos 6.5 編譯安裝Nginx-1.5.13+php-5.5.10+Mysql-5.5.37
1、設定防火牆,開啟80埠、3306
複製程式碼
vi /etc/sysconfig/iptables
將
-A INPUT -m state --state NEW -m tcp -p tcp --dport 80 -j ACCEPT
-A INPUT -m state --state NEW -m tcp -p tcp --dport 3306 -j ACCEPT
加到22埠配置後面
複製程式碼
2、關閉SELINUX
vi /etc/selinux/config
#SELINUX=enforcing #註解掉
#SELINUXTYPE=targeted #註解掉#增加
重啟centos reboot -n
3、系統約定
軟體原始碼套件存放位置:/usr/local/src
原始碼包編譯安裝位置:/usr/local/軟體名字
nginx(目前穩定版)http://nginx.org/download/nginx-1.5.13.tar.gz
下載pcre(支援nginx偽靜態)http://sourceforge.net/projects/pcre/files/pcre/ 8.35/pcre-8.35.tar.gz
下載MySQL http://mirrors.sohu.com/mysql/MySQL-5.5/mysql-5.5.37.tar.gz
下載php http://ar2.php.net/ get/php-5.5.10.tar.gz/from/this/mirror
下載cmake(MySQL編譯工具) http://www.cmake.org/files/v2.8/cmake-2.8.8.tar.gz
下載libmcrypt(PHPlibmcrypt模組)
http://nchc.dl.sourceforge.net/project/mcrypt/Libmcrypt/2.5.8/libmcrypt-2.5.8.tar.gz
5、安裝編譯工具及程式庫檔案(使用CentOS yum指令安裝)
yum install make apr* autoconf automake curl-devel gcc gcc-c++ zlib-devel openssl kerssl-devel pcre-devel gd kernel keyutils patch perl kernel-devel pcre-devel gd kernel* mpils patch perl kernel-frers compatw-gor r為 wwwwwheb r r對-ppl keyutils-libs-devel libcom_err-devel libsepol-devel
libselinux-devel krb5-devel zlib-devel libXpm* freetype libjpeg* libpng* php-common php-gd ncurses* libtool* libxml2 libxml2-devel patch mhash 6、 cd cmake-2.8.8
./configure
gmake
gmake install
7、安裝mysql
複製程式碼
groupadd mysql #新增mysql群組
useradd -g mysql my -my /bin/false #my/bin/false #my群組,不允許mysql使用者直接登入系統
mkdir -p /data/mysql #建立MySQL資料庫存放目錄
chown -R mysql:mysql /data/mysql #設定權限
mkdir -p /usr/local/my #建立安裝安裝目錄
tar zxvf mysql-5.5.37.tar.gz
cd mysql-5.5.37
cmake . -DCMAKE_INSTALL_PREFIX=/usr/local/mysql -DMY_DCMAKE_INSTALL_PREFIX=/usr/local/mysql -DMY_DATAATADIRd #安裝
cd /usr/local/mysql
cp ./support-files/my-huge.cnf /etc/my.cnf #拷貝設定檔(注意:/etc目錄下方預設有一個my.cnf,直接覆寫即可)
vi /etc/my.cnf #編輯設定檔,在[mysqld] 部分增加
datadir = /data/mysql #新增MySQL資料庫路徑
./scripts/mysql_install_db --user=my #生成sqlsql系統資料庫cp ./support-files/mysql.server /etc/rc.d/init.d/mysqld #把Mysql加入系統啟動
chmod 755 /etc/init.d/mysqld #增加執行權限
chkconfig mysqld on #加入開機啟動
vi /etc/rc.d/init.d/mysqld #編輯
basedir = /usr/local/mysql #MySQL程式安裝路徑
datadir = /data/mysql #MySQl資料庫存放目錄
service mysqld start #啟動vi /etc/profile #把mysql服務加入系統環境變數:在最後加上下面這一行
export PATH=$PATH:/usr/local/mysql/bin
下面這兩行把myslq的函式庫檔案連結到系統預設的位置,這樣你在編譯類似PHP等軟體時可以不用指定mysql的函式庫檔案位址。
ln -s /usr/local/mysql/lib/mysql /usr/lib/mysql
ln -s /usr/local/mysql/include/mysql /usr/include/mysql
shutdown - now等待系統重新啟動之後繼續在終端命令列下面操作
mysql_secure_installation #設定Mysql密碼
根據提示按Y 回車輸入2次密碼
或直接修改密碼/usr/local/mysql/bin/mysqladmin -u root -p password "123456" #修改密碼
service mysqld restart #重啟
複製代碼
8、安裝PCRE
複製代碼
cd /usr/local/src
mkdir /usr/local/pcrev-83. cd pcre-8.35
./configure --prefix=/usr/local/pcre
make
make install
複製程式碼
9、安裝nginx
複製程式碼
cd /us/local/usersrc www -s /bin/false
tar zxvf nginx-1.5.13.tar.gz
cd nginx-1.5.13
./configure --prefix=/usr/local/nginx --without-http_memcached_module --user --group=www --with-http_stub_status_module --with-openssl=/usr/ --with-pcre=/usr/local/src/pcre-8.35
make
make install
#設定nginx自啟動,加入下列腳本
vi /etc/init.d/nginx
#!/bin/bash
# nginx Startup script for the Nginx HTTP Server
# it is v.0.0.2 version.
# chkconfig: - 85 1510. is a high-performance web and proxy server.
# It has a lot of features, but it's not for everyone.
# processname: nginx /nginx/conf/nginx.conf
nginxd=/usr/local/nginx/sbin/nginx
nginx_c/local/nginx/conf/nginx.conf
nginx_pid=/var/run/nginx. ="nginx"
# Source function library.
. /etc/rc.d/init.d/functions
# Source networking configuration.
. /etc/sysconfig/network
# Check that networking is . NETWORKING} = "no" ] && exit 0
[ -x $nginxd ] || exit 0
# Start nginx daemons functions.
start() {
if [ -e $nginx_pid ]readthen
start() {
if [ -e $nginx_pid ]readthen
..."
exit 1
fi
echo -n $"Starting $prog: "
daemon $nginxd -c ${nginx_config}
/subsys/nginx
return $RETVAL
}
# Stop nginx daemons functions.
stop() {
echo -n $kill"Stop $prog: " ETVAL=$?
echo
[ $RETVAL = 0 ] && rm -f /var/lock/subsys/nginx /var/run/nginx.pid
}
# reload nginx service functions.
reload() {
echo -n $"Reloading $prog: "🎠 HUP `cat ${nginx_pid}`
killproc $nginxd -HUP
RETVAL=$?
echo
}
# See how weere called. ;;
stop)
stop
;;
reload)
reload
;;
restart)
us)
status $prog
RETVAL=$?
;;
*)
| stop|restart|reload|status|help}"
exit 1
esac
exit $RETVAL
chmod 775 /etc/rc.d/init.d/nginx
chkconfig nginx on
/etc/rcgind/startin
10、安裝libmcrypt
cd /usr/local/src
tar zxvf libmcrypt-2.5.8.tar.gz
cd libmcrypt-2.5.8
./configure
makecinstad cd /usr/local/src
tar -zvxf php-5.5.10.tar.gz
cd php-5.5.10
mkdir -p /usr/local/php5
./configure --prefix=/usr/local/ php5 --with-config-file-path=/usr/local/php5/etc --with-mysql=/usr/local/mysql --with-mysqli=/usr/local/mysql/bin/mysql_config --with -mysql-sock=/tmp/mysql.sock --with-gd --with-iconv --with-zlib --enable-xml --enable-bcmath
--enable-shmop --enable-sysvsem --enable-inline-optimization --with-curlwrappers --enable-mbregex --enable-fpm --enable-mbstring --enable-ftp --enable-gd-native- ttf --with-openssl --enable-pcntl --enable-sockets --with-xmlrpc --enable-zip --enable-soap
--with-pear --with-gettext --enable-session --with-mcrypt --with-curl
make----------------------- ------------- ------------- ------------------------ ------------- ------------- ------------------------ --------
make install
cp php.ini-生產/usr/local/php5/etc /php.ini
rm -rf /etc/php.ini
ln -s /usr/local/php5 /etc/php.ini /etc/php.ini
cp /usr/local/php5/etc/php-fpm .conf.default /usr/local/php5/etc/php-fpm.conf
vi /usr/localvi /usr/local /php5/etc/php-fpm.conf
user = www #設定php-fpm運行帳號為www
group = www #設定php-fpm運行組為www
pid = run/php-fpm.pid #取消前面的分號
cp /usr/local/src/php- 5.5.10/sapi/fpm/init.d.php -fpm /etc/rc.d/init.d/php-fpm#複製php-fpm到啟動目錄
chmod +x /etc/rc.d/init. d/php-fpm #新增執行權限
chkconfig php- fpm on #設定開機啟動
vi /usr/local/php5/etc/php.ini #編輯設定檔
修改為:date.timezone = PRC #設定時區
複製程式碼
12、設定nginx支援php
複製程式碼
vi /usr/local/nginx/conf/nginx.conf #編輯程式設定檔,需做如下修改user www www; #修改首行user註釋,Nginx運行組為www,www;必須與/usr/local/php5/etc/php-fpm.conf中的user,group配置相同,否則php運行出錯
index index.php index . html 索引.htm; #新增index.php
#將PHP腳本代理給FastCGI伺服器,監聽127.0.0.1:9000
location ~ .php$ {
root html;
fastcgi_pass 127.0.0.1:9000;
fastcgi_pass 127.0.0.1:9000;
_mRIPindex. document_root$fastcgi_script_name;
包括fastcgi_params;
}
#取消FastCGI伺服器部分位置的註解,並要注意fastcgi_param行的參數,改為
$document_root$fastcgi_script_name,或使用絕對路徑
/etc/init.d/nginx restart #重啟nginx 複製、測試
複製程式碼
cd /usr/local/nginx/html/ #進入nginx預設網站根目錄
rm -rf /usr/local/nginx/html/*刪除#預設測試頁
vi index.php #編輯
phpinfo();
chown www.www /usr/local/nginx/html/ -R #設定目錄擁有者
chmod 700 /usr/local/nginx/html/ -R #設定目錄權限
shutdown -r now #重啟系統
複製程式碼
14、相關指令
service nginx restart #重啟nginx
service mysqld restart #重啟mysql
/usr/local/php5/sbin/php-fpm #啟動php-fpm
/etc/rc. .d/php-fpm restart #重啟php-fpm
/etc/rc.d/init.d/php-fpm stop #停止php-fpm
問題:
在Linux下安裝PHP過程中,編譯時出現configure: error: libjpeg.(a|so) not found 錯誤的解決方法
檢查之後發現已經安裝了libjpeg,但是在/usr/lib目錄下沒有libjpeg.so這個文件,在/usr/lib64下是有的,雖然使用–with-jpeg-dir=/usr/lib64 仍然無效,最後用
[root@ www.linuxidc.com ~]#ln -s /usr/lib64/libjpeg.so /usr/lib/libjpeg.so
問題解決,libpng報錯的解決方法同樣
以上就介紹了Centos 65編譯安裝Nginx-1513+php-5510+Mysql-5537,包括了方面的內容,希望對PHP教程有興趣的朋友有所幫助。