标签:
一、安装前
1、关闭linux的安全机制
vim /etc/selinux/config
SELINUX=enforcing 改为 SELINUX=disabled
2、关闭iptables防火墙
vim /etc/sysconfig/iptables #把里边的条例全部dd删除掉,wq保存退出
service iptables stop #关闭iptables
chkconfig iptables off #开机不自启动iptables
3、配置yum源(本地,网络都可以)#如果能上网的话建议配置网络yum源
详细如何配置yum请阅读 http://blog.csdn.net/allen_a/article/details/51198585
4、重启系统
reboot
二、安装篇
yum list
yum clean all
yum -y install pcre-devel zlib-devel
yum -y install gcc* gcc-*
yum remove httpd
rpm -qa httpd
1)编译安装nginx
A.安装支持软件
yum -y install pcre-devel zlib-devel
B.创建运行用户、组
useradd -M -s /sbin/nologin nginx
C.编译安装Nginx
tar zxvf nginx-1.6.0
cd nginx-1.6.0
./configure --prefix=/usr/local/nginx --user=nginx --group=nginx --with-http_stub_status_module
make && make install
/usr/local/nginx/sbin/nginx # 启动Nginx
访问Nginx服务器的IP,会出现 欢迎来到Nginx
nginx开启,关闭命令
killall -s HUP nginx
killall -1 nginx
killall -s QUIT nginx
killall -3 nginx
查看日志信息
cd /usr/local/nginx/logs/
natstat -anpt | grep nginx
优化应用程序控制
vim /etc/init.d/nginx
#!/bin/bash
# chkconfig: - 99 20
# description: Nginx Server Control Script
PROC="/usr/local/nginx/sbin/nginx"
PID="/usr/local/nginx/logs/nginx.pid"
case "$1" in
start)
$PROC
$PROG
;;
stop)
kill -s QUIT $(cat $PID)
;;
restart)
$0 stop
$0 start
;;
reload)
kill -s HUP $(cat $PID)
;;
status)
[ -f $PID ] &> /dev/null
if [ $? -eq 0 ]
then
netstat -anpt | grep nginx
else
echo "Nginx is not running."
fi
;;
*)
echo "Usage: $0 {start|stop|restart|reload|status}"
esac
exit 0
检查语法
nginx -t
检测安装环境,卸载rpm的应用程序
yum remove httpd mysql php
1、安装MySQL数据库
1)编译安装MySQL数据库
yum -y install ncurses-devel
tar zxvf cmake-2.8.6.tar.gz
cd cmake-2.8.6
./configure
gmake
gmake install
tar zxvf mysql-5.5.22.tar.gz
cd mysql-5.5.22
cmake -DCMAKE_INSTALL_PREFIX=/usr/local/mysql -DDEFAULT_CHARSET=utf8 -DDEFAULT_COLLATION=utf8_general_ci -DWITH_EXTRA_CHARSETS=ALL -DSYSCONFIGDIR=/etc
make && make install
2)优化调整
rm -rf /etc/my.cnf
cp support-files/my-medium.cnf /etc/my.cnf
cp support-files/mysql.server /etc/rc.d/init.d/mysqld
chmod +x /etc/rc.d/init.d/mysqld
chkconfig --level 35 mysqld on
echo "PATH=$PATH:/usr/local/mysql/bin" >> /etc/profile
. /etc/profile 或者 source /etc/profile
3)初始化数据库
groupadd mysql
useradd -M -s /sbin/nologin mysql -g mysql
chown -R mysql:mysql /usr/local/mysql/
/usr/local/mysql/scripts/mysql_install_db --basedir=/usr/local/mysql/ --datadir=/usr/local/mysql/data/ --user=mysql
4)启动数据库
service mysqld start
mysqladmin -u root password ‘pwd123‘
mysql -u root -p
2、安装PHP解析环境
1)编译安装PHP
yum -y install gd libxml2 libxml2-devel libjpeg-devel libpng-devel
tar zxvf php-5.3.28.tar.gz
cd php-5.3.28
./configure --prefix=/usr/local/php5/ --with-gd --with-zlib --with-mysql=/usr/local/mysql --with-config-file-path=/usr/local/php5 --enable-mbstring --enable-fpm --with-jpeg-dir=/usr/lib
make && make install
测试:make test
2)安装后的调整
cp php.ini-development /usr/local/php5/php.ini
ln -s /usr/local/php5/bin/* /usr/local/bin/
ln -s /usr/local/php5/sbin/* /usr/local/sbin/
3)安装ZendGuardLoader
tar zxvf ZendGuardLoader-php-5.3-linux-glibc23-x86_64.tar.gz
cd ZendGuardLoader-php-5.3-linux-glibc23-x86_64/php-5.3.x/
cp ZendGuardLoader.so /usr/local/php5/lib/php/
vim /usr/local/php5/php.ini
zend_extension=/usr/local/php5/lib/php/ZendGuardLoader.so
zend_loader.enable=1
service nginx restart
3)配置Nginx支持PHP环境
1)启动php-fpm进程
cd /usr/local/php5/etc/
cp php-fpm.conf.default php-fpm.conf
useradd -M -s /sbin/nologin php
vim php-fpm.conf
pid = run/php-fpm.pid(去掉分号)
user = php
group = php
pm.start 20
pm.min 5
pm.max 35
pm.max_children 50
启动php-fpm进程
/usr/local/sbin/php-fpm
netstat -apnt | grep php-fpm
netstat -apnt | grep nginx
netstat -apnt | grep mysqld
service nginx restart 或 reload
2)配置Nginx支持PHP解析
location ~ \.php$ {
root html;
fastcgi_pass 127.0.0.1:9000;
fastcgi_index index.php;
#fastcgi_param SCRIPT_FILENAME /scripts$fastcgi_script_name;
include fastcgi.conf;
}
3)php页面的测试访问
vim t.php
<?php
phpinfo();
?>
vim test.php
<?php
$link=mysql_connect(‘localhost‘,‘root‘,‘pwd123‘); //单引号
if($link)
echo "恭喜你,数据库连接成功!";
mysql_close();
?>
标签:
原文地址:http://www.cnblogs.com/moyand/p/5417484.html