nginx,mysql,php环境筹建

nginx,mysql,php环境筹建

nginx,mysql,php环境搭建

1、安装Linux Nginx

# tar -zxvf nginx-0.8.5.tar.gz 

# cd nginx-0.8.5 

# ./configure –prefix=/usr/local/nginx –with-http_stub_status_module –with-http_ssl_module –with-http_gzip_static_module –with-http_ssl_module(安装路径及

所需依赖包)–prefix(安装路径)

# make && make install

启动nginx# /usr/local/nginx/sbin/nginx

停止nginx# kill -QUIT `cat /usr/local/nginx/logs/nginx.pid`

重启nginxkill -HUP `cat /usr/local/nginx/logs/nginx.pid`

添加到自启动# echo “/usr/local/nginx/sbin/nginx”>>/etc/rc.local

或者用 /usr/local/nginx/sbin/nginx 启动 nginx

/usr/local/nginx/sbin/nginx -s quit 退出nginx

/usr/local/nginx/sbin/nginx -s reload 重新载入

还需要安装 apt-get install spawn-fcgi

每次运行的时候执行:告诉php需要相应的端口号 跟之前做的java一样

spawn-fcgi -a 127.0.0.1 -p 9000 -C 5 -u www-data -g www-data -f

/usr/bin/php-cgi(必须滴)

2、spawn-fcgi,用来启动PHP的FastCGI模式

(linux下载包用 wget方式 或者可以直接安装用apt-get install spawn-fcgi方式)

wget http://www.lighttpd.net/download/spawn-fcgi-1.6.3.tar.gz

tar -zxf spawn-fcgi-1.6.3.tar.gz

cd spawn-fcgi-1.6.3

./configure –bindir=/usr/bin –libdir=/usr/lib –prefix=/etc

make&&make install

3、安装mysql

# tar -zxvf mysql-5.0.67.tar.gz 

# cd mysql-5.0.67 

# groupadd mysql 

# useradd -g mysql -s /sbin/nologin -M mysql 

# ./configure –prefix=/usr/local/mysql –with-charset=gbk –with-extra-charset=all –enable-hread-safe-client

–enable-local-infile –with-low-memory 

# make && make install 

# cp support-files/my-medium.cnf     /etc/my.cnf 

# chown -R mysql.mysql /usr/local/mysql/ 

# /usr/local/mysql/bin/mysql_install_db –user=mysql

# chown -R root.root /usr/local/mysql/ 

# chown -R mysql.mysql /usr/local/mysql/var/

启动数据库服务,并添加到自启动

# /usr/local/mysql/bin/mysqld_safe –user=mysql & 

#cp     support-files/mysql.server     /etc/rc.d/init.d/mysqld 

#chmod     755     /etc/rc.d/init.d/mysqld

加入自动启动服务队列:

#chkconfig –add mysqld 

#chkconfig     –level     345     mysqld     on添加root密码 

# /usr/local/mysql/bin/mysqladmin -u root password “123456” 

测试一下:# /usr/local/mysql/bin/mysql -u root -p输入密码:123456,看能不能进入到数据库

配置库文件搜索路径

# echo “/usr/local/mysql/lib/mysql”>>/etc/ld.so.conf 

# ldconfig 

# ldconfig -v 

添加/usr/local/mysql/bin到环境变量PATH中 

#echo “export PATH=$PATH:/usr/local/mysql/bin”>>/etc/profile 

#source /etc/profile

4、安装PHP

这里产生的是可执行文件,和apache的不一样,和apache结合的时候产生的是动态库

# tar -jxvf php-5.2.6.tar.bz2 

# gzip -cd php-5.2.6-fpm-0.5.9.diff.gz |patch -d php-5.2.6 -p1 

# cd php-5.2.6 

# ./configure –prefix=/usr/local/php –with-mysql=/usr/local/mysql –enable-fastcgi –enable-fpm  

–with-config-file-path=/usr/local/php/etc –enable-force-cgi-redirect 

# make && make install 

# cp php.ini-recommended /usr/local/php/etc/php.ini 

# vi /usr/local/php/php-fpm.conf

(1)<value name=”listen_address”>127.0.0.1:9000</value>修改为<value name=”listen_address”>IP:9000</value> 

//本机就用默认的127.0.0.1 

(2)下面这两行去掉注释并修改                           

<value name=”sendmail_path”>/usr/sbin/sendmail -t -i</value>

<value name=”display_errors”>1</value>

(3)<value name=”user”>nobody</value>      //去注释 

(4)<value name=”group”>nobody</v

nginx,mysql,php环境筹建

相关文章:

你感兴趣的文章:

标签云: