Redhat Enterprise5.5下安装nginx+php+mysql
nginx版本:nginx-1.0.6.tar.gz
php版本:php-5.2.17.tar.gz
php-5.2.17-fpm-0.5.14.diff.gz
mysql版本:mysql-5.5.15.tar.gz
一、安装nginx
安装pcre
[root@RHE5 soft]# tar zxvf pcre-8.13.tar.gz
[root@RHE5 soft]# cd pcre-8.13
[root@RHE5 pcre-8.13]# ./configure --prefix=/usr/local/pcre
[root@RHE5 pcre-8.13]# make
[root@RHE5 pcre-8.13]# make install
[root@RHE5 soft]# tar zxvf nginx-1.0.6.tar.gz
[root@RHE5 soft]# cd nginx-1.0.6
[root@RHE5 pcre-8.13]# ./configure --prefix=/usr/local/nginx --with-pcre=/soft/pcre-8.13 --with-http_stub_status_module
[root@RHE5 pcre-8.13]# make
[root@RHE5 pcre-8.13]# make install
二、安装mysql
安装cmake
[root@RHE5 soft]# tar zxvf cmake-2.8.5.tar.gz
[root@RHE5 cmake-2.8.5]# ./configure
[root@RHE5 cmake-2.8.5]# make
[root@RHE5 cmake-2.8.5]# make install
[root@RHE5 soft]# tar zxvf mysql-5.5.15.tar.gz
[root@RHE5 soft]# cd mysql-5.5.15
[root@RHE5 mysql-5.5.15]# cmake -DCMAKE_INSTALL_PREFIX=/usr/local/mysql
[root@RHE5 mysql-5.5.15]# make
[root@RHE5 mysql-5.5.15]# make install
[root@RHE5 mysql-5.5.15]# cp support-files/my-medium.cnf /etc/my.cnf
[root@RHE5 mysql-5.5.15]# groupadd mysql
[root@RHE5 mysql-5.5.15]# useradd mysql -g mysql
[root@RHE5 mysql-5.5.15]# /usr/local/mysql/scripts/mysql_install_db &
[root@RHE5 mysql]# chown mysql.mysql -R data
[root@RHE5 mysql]# /usr/local/mysql/bin/mysqld_safe --user=mysql&
[root@RHE5 bin]./mysql
[root@RHE5 support-files]# cp mysql.server /etc/init.d/mysqld
[root@RHE5 support-files]# chmod 755 /etc/init.d/mysqld
[root@RHE5 support-files]# chkconfig --add mysqld
[root@RHE5 support-files]# chkconfig mysqld on
[root@RHE5 support-files]# service mysqld start
Starting MySQL [确定]
三、安装php
安装GD
[root@RHE5 soft]# tar zxvf gd-2.0.35.tar.gz
[root@RHE5 soft]# cd gd-2.0.35
[root@RHE5 gd-2.0.35]# ./configure --prefix=/usr/local/gd
[root@RHE5 gd-2.0.35]# make
[root@RHE5 gd-2.0.35]# make install
安装libpng
[root@RHE5 soft]# tar zxvf libpng-1.5.4.tar.gz
[root@RHE5 soft]# cd libpng-1.5.4
[root@RHE5 libpng-1.5.4]# ./configure --prefix=/usr/local/png
[root@RHE5 libpng-1.5.4]# make
[root@RHE5 libpng-1.5.4]# make install
安装php
[root@RHE5 soft]# tar zxvf php-5.2.17.tar.gz
[root@RHE5 soft]# gzip -cd php-5.2.17-fpm-0.5.14.diff.gz |patch -d php-5.2.17 -p1
[root@RHE5 soft]# cd php-5.2.17
[root@RHE5 php-5.2.17]# ./configure --prefix=/usr/local/php --with-gd=/usr/local/gd --with-png-dir=/usr/local/png --with-mysql=/usr/local/mysql --enable-fastcgi --enable-fpm
[root@RHE5 php-5.2.17]# make
[root@RHE5 php-5.2.17]# make install
[root@RHE5 php-5.2.17]# cp php.ini-dist /usr/local/php/lib/php.ini
四、整合nginx和php
vi /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 /usr/local/nginx/html$fastcgi_script_name;
include fastcgi_params;
}
location /nginx_status {
stub_status on;
access_log off;
allow 192.168.0.207;设置为可访问该状态信息的ip
deny all;
}
启动nginx
[root@RHE5 soft]# /usr/local/nginx/sbin/nginx
[root@RHE5 soft]# /usr/local/php/sbin/php-fpm start
文章评论