CentOS6.5服务器搭建Nginx+Php5.3+Mysql5.1+phpMyAdmin环境
修改主机名
编辑/etc/sysconfig/network文件
nano /etc/sysconfig/network
HOSTNAME=主机名
编辑/etc/hosts文件添加一条公网IP,不添加hostname -f会报unknown host的错误
nano /etc/hosts
公网IP localhost 主机名
编辑创建资源库
nano /etc/yum.repos.d/nginx.repo
添加如下内容
[nginx]
name=nginx repo
baseurl=http://nginx.org/packages/centos/$releasever/$basearch/
gpgcheck=0
enabled=1
安装Nginx
yum install nginx
查看Nginx状态
service nginx status
启动Nginx查看配置文件
service nginx start
nginx -t
让Nginx随机启动并验证
chkconfig nginx on
chkconfig --list nginx
Nginx配置文件目录
cd /etc/nginx/conf.d
复制配置文件创建新站点
cp default.conf blog.phpwebhome.com.conf
站点blog.phpwebhome.com.conf配置文件内容
server {
listen 80;
server_name blog.phpwebhome.com;
root /home/www/blog.phpwebhome.com;
#charset koi8-r;
#access_log /var/log/nginx/log/host.access.log main;
location / {
index index.php index.html index.htm;
}#error_page 404 /404.html;
# redirect server error pages to the static page /50x.html
#
error_page 500 502 503 504 /50x.html;
location = /50x.html {
root /usr/share/nginx/html;
}# proxy the PHP scripts to Apache listening on 127.0.0.1:80
#
#location ~ \.php$ {
# proxy_pass http://127.0.0.1;
#}# pass the PHP scripts to FastCGI server listening on 127.0.0.1:9000
#
location ~ \.php$ {
root /home/www/blog.phpwebhome.com;
fastcgi_pass 127.0.0.1:9000;
fastcgi_index index.php;
fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
fastcgi_param PHP_VALUE "open_basedir=$document_root:/tmp/";
include fastcgi_params;
}# deny access to .htaccess files, if Apache's document root
# concurs with nginx's one
#
#location ~ /\.ht {
# deny all;
#}
}
Nginx重新载入配置文件并重启
service nginx reload
service nginx restart
安装启动PHP5.3
yum install php-fpm
service php-fpm start
查看PHP5.3状态并加载到随机启动项
service php-fpm status
chkconfig php-fpm on
chkconfig --list php-fpm
CENTOS6.5 64位系统添加资源库
资源库http://iuscommunity.org/pages/Repos.html
cat /etc/redhat-release #查看系统版本
uname -a #查看多少位
wget http://dl.iuscommunity.org/pub/ius/stable/CentOS/6/x86_64/epel-release-6-5.noarch.rpm
rpm -ivh epel-release-6-5.noarch.rpm
yum repolist #查看系统中的资源
安装PHP5.3扩展组建
yum install php-pecl-apc php-mysql php-gd php-mcrypt libmcrypt libmcrypt-devel php-pear php-mbstring php-xmlrpc php-dom
service php-fpm restart
修改目录用户权限
nano /etc/php-fpm.d/www.conf
将
user = apache
修改为
user=nginx
安装mysql并启动
yum install mysql-server
service mysqld start
加载MYSQL随机启动项
chkconfig mysqld on
chkconfig --list mysqld
配置mysql
mysql_secure_installation
安装phpmyadmin
到官网下载http://www.phpmyadmin.net/downloads/相对应版本
下载后上传解压
解决运行phpMyAdmin出现Cannot start session without errors... 的错误
cd /var/lib/php/
mkdir session
chown -R nginx session
chmod -R 755 session
解决phpMyAdmin 高级功能尚未完全设置,部分功能未激活 的错误
登录phpmyadmin导入安装包examples目录下的create_tables.sql文件
配置config.inc.php文件
配置php-fpm
nano /etc/php.ini #配置下文件
reboot #重启下主机就OK了
转载请注明:RAIN MAN » CentOS6.5服务器搭建Nginx+Php5.3+Mysql5.1+phpMyAdmin环境
还没有人抢沙发呢~