标签:启动mysql clu index 显示 service 远程登录 lte 关闭selinux 删除
一、准备:
1.配置防火墙,开启80端口、3306端口
编辑 /etc/sysconfig/iptables,添加如下条目:
-A INPUT -m state --state NEW -m tcp -p tcp --dport 80 -j ACCEPT(允许80端口通过防火墙) -A INPUT -m state --state NEW -m tcp -p tcp --dport 3306 -j ACCEPT(允许3306端口通过防火墙)
添加好的规则如下:
[root@localhost ~]# vim /etc/sysconfig/iptables # Firewall configuration written by system-config-firewall # Manual customization of this file is not recommended. *filter :INPUT ACCEPT [0:0] :FORWARD ACCEPT [0:0] :OUTPUT ACCEPT [0:0] -A INPUT -m state --state ESTABLISHED,RELATED -j ACCEPT -A INPUT -p icmp -j ACCEPT -A INPUT -i lo -j ACCEPT -A INPUT -m state --state NEW -m tcp -p tcp --dport 22 -j ACCEPT -A INPUT -m state --state NEW -m tcp -p tcp --dport 80 -j ACCEPT -A INPUT -m state --state NEW -m tcp -p tcp --dport 3306 -j ACCEPT -A INPUT -j REJECT --reject-with icmp-host-prohibited -A FORWARD -j REJECT --reject-with icmp-host-prohibited COMMIT
#最后重启防火墙使配置生效
[root@localhost ~]#/etc/init.d/iptables restart
或者
[root@localhost ~]# service iptables restart
2.2、关闭SELINUX
vi /etc/selinux/config #SELINUX=enforcing #注释掉 #SELINUXTYPE=targeted #注释掉 SELINUX=disabled #增加 :wq 保存,关闭 shutdown -r now #重启系统
3、配置CentOS 第三方yum源(CentOS默认的标准源里没有nginx软件包)
[root@localhost ~]yum install wget #安装下载工具wget [root@localhost ~]# wget http://www.atomicorp.com/installers/atomic #下载atomic yum源 [root@localhost ~]# sh ./atomic #安装 [root@localhost ~]yum check-update #更新yum软件包
二.安装篇
1、安装nginx
[root@localhost ~]# yum install nginx -y #安装nginx,根据提示,输入Y安装即可成功安装 [root@localhost ~]# service nginx start #启动 Starting nginx: [ OK ]
[root@localhost ~]# chkconfig nginx on #设为开机启动
[root@localhost ~]#rm -rf /usr/share/nginx/html/* #删除ngin默认测试页
2、安装MySQL
[root@localhost ~]# yum install mysql mysql-server #询问是否要安装,输入Y即可自动安装,直到安装完成 [root@localhost ~]# /etc/init.d/mysqld start #启动MySQL [root@localhost ~]# chkconfig mysqld on #设为开机启动
[root@localhost ~]# mv /etc/my.cnf{,.bak}
[root@localhost ~]# cp /usr/share/mysql/my-medium.cnf /etc/my.cnf #拷贝配置文件
2.2、为root账户设置密码
[root@localhost ~]# mysql_secure_installation #初始化MySQL
回车,根据提示输入Y
Enter current password for root (enter for none): <---输入现在的root密码,因为我们还没设置,直接回车
Set root password? [Y/n] Y <---是否设定root密码,当然设置了,输入Y回车
New password: <---输入root密码,并回车,输入的过程中不会有任何显示
Re-enter new password: <---再次输入root密码,并回车,输入的过程中不会有任何显示
Remove anonymous users? [Y/n] Y <---是否删除匿名用户,删除,输入Y回车
Disallow root login remotely? [Y/n] Y <---是否删禁止root用户远程登录,当然禁止,输入Y回车
Remove test database and access to it? [Y/n] <---是否删除测试数据库test,看个人喜好
Reload privilege tables now? [Y/n] Y <---刷新权限,输入Y回车
最后出现:Thanks for using MySQL!
MySql密码设置完成,重新启动 MySQL:
[root@localhost ~]# /etc/init.d/mysqld start
其他操作:
[root@localhost ~]# /etc/init.d/mysqld stop #停止 [root@localhost ~]# service mysqld restart #重启
3、安装PHP
3.1、安装PHP
[root@localhost ~]# yum install php #根据提示输入Y直到安装完成
3.2、安装PHP组件,使PHP支持 MySQL、PHP支持FastCGI模式
[root@localhost ~]# yum install php-mysql php-gd libjpeg* php-imap php-ldap php-odbc php-pear php-xml php-xmlrpc php-mbstring php-mcrypt php-bcmath php-mhash libmcrypt libmcrypt-devel php-fpm -y
[root@localhost ~]#/etc/init.d/mysqld restart #重启MySql
[root@localhost ~]#/etc/init.d/nginx restart #重启nginx
[root@localhost ~]#/etc/rc.d/init.d/php-fpm start #启动php-fpm
[root@localhost ~]#chkconfig php-fpm on #设置开机启动
三.配置篇
1、配置nginx支持php
[root@localhost ~]# cp /etc/nginx/nginx.conf{,.bak}
[root@localhost ~]# vim /etc/nginx/nginx.conf #编辑/etc/nginx/nginx.conf
user nginx nginx; #修改nginx运行账号为:nginx组的nginx用户
[root@localhost ~]# cp /etc/nginx/conf.d/default.conf{,.bak} #备份原有配置文件
[root@localhost ~]# vim /etc/nginx/conf.d/default.conf #编辑/etc/nginx/conf.d/default.conf
location / {
root /usr/share/nginx/html;
index index.php index.html index.htm; #增加index.php
}
# pass the PHPscripts to FastCGI server listening on 127.0.0.1:9000
location ~ \.php$ {
root html;
fastcgi_pass 127.0.0.1:9000;
fastcgi_index index.php;
fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
include fastcgi_params;
}
#取消FastCGI server部分location的注释,并要注意fastcgi_param行的参数,改为$document_root$fastcgi_script_name,或者使用绝对路径
2、配置php
[root@localhost ~]# cp /etc/php.ini{,.bak}
date.timezone= PRC
expose_php = Off
3、配置php-fpm
[root@localhost ~]# cp /etc/php-fpm.d/www.conf{,.bak} [root@localhost ~]# vim /etc/php-fpm.d/www.conf
user = nginx #修改用户为nginx
group = nginx #修改组为nginx
[root@localhost ~]# /etc/init.d/mysqld restart
[root@localhost ~]# /etc/init.d/nginx restart
[root@localhost ~]# /etc/rc.d/init.d/php-fpm restart
四.测试篇
[root@localhost ~]# cd /usr/share/nginx/html/ [root@localhost html]# vim index.php <?php phpinfo(); ?>
[root@localhost html]# chown nginx.nginx /usr/share/nginx/html/ -R #设置目录所有者
[root@localhost html]# chmod 700 /usr/share/nginx/html/ -R #设置目录权限
在客户端浏览器输入服务器IP地址,可以看到相关的配置信息!
备注
nginx默认站点目录是:/usr/share/nginx/html/ 权限设置:chown nginx.nginx/usr/share/nginx/html/ -R MySQL数据库目录是:/var/lib/mysql 权限设置:chown mysql.mysql -R /var/lib/mysql
标签:启动mysql clu index 显示 service 远程登录 lte 关闭selinux 删除
原文地址:http://www.cnblogs.com/zhongguiyao/p/7657443.html