一、Ngnix环境搭建
参考:
http://blog.csdn.net/a657941877/article/details/25084473
http://leyewen.blog.163.com/blog/static/25060614201243105412500/
http://shiyanjun.cn/archives/72.html
我这里使用nginx的yum在线安装
wget http://nginx.org/packages/centos/6/noarch/RPMS/nginx-release-centos-6-0.el6.ngx.noarch.rpm
安装源库
chmod+x nginx-release-centos-6-0.el6.ngx.noarch.rpm
rpm-i nginx-release-centos-6-0.el6.ngx.noarch.rpm
安装nginx
yum install nginx
安装完成后
默认nginx配置文件: /etc/nginx/nginx.conf 【nginx主要的配置文件】
默认nginx的ssl配置文件: /etc/nginx/conf.d/ssl.conf 【配置SSL证书的,也可以并入到nginx.conf文件里】
默认nginx的虚拟主机配置文件: /etc/nginx/conf.d/virtual.conf 【如同Apache的虚拟主机配置,也可以并入到nginx.conf文件里】
默认的web_root文件夹路径: /usr/share/nginx/html 【web目录夹,放置Magento主程序】
配置iptables
iptables-I INPUT5-p tcp--dport80-j ACCEPT
启动nginx
service nginx start
打开IP地址 可见“Welcome to nginx!”表示安装成功。
=============================================================
以下自己加的,非root启动nginx
先关闭默认启动的nginx
chkconfig--level2345nginx off
复制/etc/nginx/nginx.conf到别的地方
cp/etc/nginx/nginx.conf/home/user/etc/nginx/nginx.conf
启动
/usr/sbin/nginx-c/home/user/etc/nginx/nginx.conf
You can kill it using:
sudo fuser -k 80/tcp
And then try restarting nginx again:
service nginx start
关闭
killall nginx
=======================================================
conf改成下如下
user nginx;
worker_processes1;
error_log/home/user/log/nginx/error.log warn;
pid/home/user/log/nginx/run/nginx.pid;
events{
worker_connections1024;
}
http{
include/etc/nginx/mime.types;
default_type application/octet-stream;
log_format main'$remote_addr - $remote_user [$time_local] "$request" '
'$status $body_bytes_sent "$http_referer" '
'"$http_user_agent" "$http_x_forwarded_for"';
access_log/home/user/log/nginx/access.log main;
sendfile on;
#tcp_nopush on;
keepalive_timeout65;
gzip on;
include/home/user/etc/nginx/conf.d/*.conf;
}
/home/user/etc/nginx/conf.d/default.conf;里面
server {
listen 8080;
注意:端口是1024以下,一定要root权限启动才可以绑定(这是Linux系统机制问题),否则非root启动会提示无法绑定端口
==========================================
非root用户启动,使用80端口:
cd/usr/sbin
发现:
-rwxr-xr-x. 1 root root 834352 Dec 12 00:57 nginx
按照网上的说法,给nginx添加s的权限:
chmod u+s nginx
再查看:
-rwsr-xr-x. 1 root root 834352 Dec 12 00:57 nginx
再次以非root启动:
root 1736 1 0 23:51 ? 00:00:00 nginx: master process /usr/sbin/nginx -c /home/user/etc/nginx/nginx.conf
nginx 1737 1736 0 23:51 ? 00:00:00 nginx: worker process
主线程还是root。子线程不一定是root了
另外:
如果nginx设置目录在/home/user下面。
/home/user一定要给o+x的权限,否则会报403 forbidden
二、PHP的配置
yum -y install libjpeg libjpeg-devel libpng libpng-devel libxml2 libxml2-devel curl curl-devel
wget http://cn2.php.net/distributions/php-5.5.12.tar.gz
tar zxvf php-5.5.12.tar.gz
cd php-5.5.12
./configure --prefix=/usr/local/php \
--with-config-file-path=/usr/local/php/etc \
--with-gd \
--with-mysql \
--with-mysqli \
--with-pdo-mysql \
--with-iconv \
--with-zlib \
--enable-xml \
--enable-inline-optimization \
--enable-fpm \
--enable-mbstring \
--with-openssl \
--without-pear \
--with-gettext \
--enable-session \
--with-curl \
--with-mhash
make && make install