一,安装(略)
二,使用root用户登录
1,使用su命令登录root用户
2,修改/etc/pam.d/gdm文件和/etc/pam.d/gdm-password
注释掉 auth required pam_succeed_if.so user != root quiet
三,网络配置:
1.设置IP地址
查看你使用的IP网卡
ifconfig -a
找到你要使用的网卡
vi /etc/sysconfig/network-scripts/ifcfg-eth0
# Intel Corporation 82801BA/BAM/CA/CAM Ethernet Controller
DEVICE=eth0
BOOTPROTO=static
#BROADCAST=59.188.15.255
HWADDR=00:02:A5:F5:80:23
IPADDR=59.188.15.117
NETMASK=255.255.255.240
#NETWORK=59.188.15.0
ONBOOT=yes
2.设置网关地址
vi /etc/sysconfig/network
NETWORKING=yes
HOSTNAME=localhost.localdomain
GATEWAY=192.168.32.1
3.设置DNS 地址
vi /etc/resolv.conf
nameserver&<60; 172.19.30.63
nameserver&<60; 172.19.30.64
search localdomain
OK设置完了
/etc/init.d/network restart
四 ,打开ssh服务
service sshd start
五 ,安装mysql
yum install mysql mysql-server
然后我们为MySQL创建系统启动连接(这样的话,MySQL就会在系统启动的时候自动启动)并且启动MySQL服务器:
chkconfig --levels 235 mysqld on
/etc/init.d/mysqld start
现在检查是否支持网络访问,运行:
netstat -tap | grep mysql
应该显示如下信息:
[root@server1 ~]# netstat -tap | grep mysql
tcp 0 0 *:mysql *:* LISTEN 1702/mysqld
[root@server1 ~]#
如果不显示,编辑/etc/my.cnf文件,并注释掉skip-networking参数:
重启 MySQL 服务器:
/etc/init.d/mysqld restart
运行
mysqladmin -u root password yourrootsqlpassword
mysqladmin -h server1.example.com -u root password yourrootsqlpassword
来为root用户设置一个密码(否则的话任何人都可以访问你的MySQL数据库!)。
六 ,安装nginx
yum install nginx
然后我们为nginx创建一个系统启动链接,并启动它:
chkconfig --levels 235 nginx on
/etc/init.d/nginx start
启动nginx:
/etc/init.d/nginx start
配置nginx:
vi /etc/nginx/nginx.conf
七 ,安装PHP
我们可以让PHP5在nginx中以FastCGI的模式工作。默认情况下Fedora中没有独立的FastCGI deamon包,因此我们使用lighttpd的FastCGI包(lighttpd-FastCGI),并同时安装php-cli和其他的PHP5模 块,例如php-mysql,它可以使你的PHP脚本支持MySQL:
yum install lighttpd-fastcgi php-cli php-mysql php-gd php-imap php-ldap php-odbc php-pear php-xml php-xmlrpc php-eaccelerator php-magickwand php-magpierss php-mapserver php-mbstring php-mcrypt php-mhash php-mssql php-shout php-snmp php-soap php-tidy
然后打开/etc/php.ini文件,并在文件的最后加入这一行line cgi.fix_pathinfo = 1:
vi /etc/php.ini
[...]
cgi.fix_pathinfo = 1
我们可以使用Lighttpd-fastcgi包中自带的/usr/bin/spawn-fcgi,启动FastCGI进程。请参考
spawn-fcgi --help
来学习更多的东西.
我们运行下列命令可以启动一个监听本地9000端口,并以nginx用户和组运行的PHP FastCGI后台:
/usr/bin/spawn-fcgi -a 127.0.0.1 -p 9000 -u nginx -g nginx -f /usr/bin/php-cgi -P /var/run/fastcgi-php.pid
当然,你并不像每次启动的时候都手动的输入这些命令,因此你可以让系统在启动时自动执行这些命令,打开/etc/rc.local…
vi /etc/rc.local
… 然后在文件的结尾添加下列命令:
[...]
/usr/bin/spawn-fcgi -a 127.0.0.1 -p 9000 -u nginx -g nginx -f /usr/bin/php-cgi -P /var/run/fastcgi-php.pid
然后修改nginx的配置文件/etc/nginx/nginx.conf
首先你可以增加worker process的数量和设置keepalive_timeout为一个合理值:
[...]
worker_processes 5;
[...]
keepalive_timeout 2;
[...]
虚拟主机定义在server{}容器中.我们使用下列命令修改默认的虚拟主机:
[...]
server {
listen 80;
server_name _;
#charset koi8-r;
#access_log logs/host.access.log main;
location / {
root /usr/share/nginx/html;
index index.php index.html index.htm;
}
error_page 404 /404.html;
location = /404.html {
root /usr/share/nginx/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 /usr/share/nginx/html;
fastcgi_pass 127.0.0.1:9000;
fastcgi_index index.php;
fastcgi_param SCRIPT_FILENAME /usr/share/nginx/html$fastcgi_script_name;
include fastcgi_params;
}
# deny access to .htaccess files, if Apache's document root
# concurs with nginx's one
#
location ~ //.ht {
deny all;
}
}
[...]
server_name www.unixbar.net; 你可以在这里通过修改www.unixbar.net 来确定你的域名
在location /部分,我在index行加入了index.php。root /usr/share/nginx/html 意思是文档路径为/usr/share/nginx/html。
对于PHP来说最重要的部分就是 location ~ /.php$ {}。取消它的注释。改变root这一行为网站的文档路径。例如root /usr/share/nginx/html。请确保把fastcgi-param行修改成了fastcgi_param SCRIPT_FILENAME /usr/share/nginx/html$fastcgi_script_name;;否则得花PHP解析器将不会找到浏览器中调用的PHP.
现在我们保存文件并重启nginx:
/etc/init.d/nginx restart
然后就可以了