朋友帮忙整了一下服务器,这次没用集成环境,手动安装了,记录如下:
感谢@阿涛 处理一些细节问题
// 服务器环境 [root@piao ~]# uname -a Linux piao 2.6.32-573.12.1.el6.x86_64 #1 SMP Tue Dec 15 21:19:08 UTC 2015 x86_64 x86_64 x86_64 GNU/Linux [root@piao ~]# cat /etc/issue CentOS release 6.7 (Final) Kernel \r on an \m yum install nginx php php-fpm mysql mysql-server // 为了方便采用yum安装各组件 全部安装到了:/etc/目录下 [root@piao conf.d]# cd /etc/init.d/ [root@piao init.d]# ls -al total 160 drwxr-xr-x. 2 root root 4096 Jan 30 15:22 . drwxr-xr-x. 10 root root 4096 Jan 30 01:50 .. -rwxr-xr-x 1 root root 3580 Oct 15 2014 auditd -rwxr-xr-x 1 root root 2826 Nov 10 18:14 crond -rw-r--r-- 1 root root 19697 Apr 10 2015 functions -rwxr-xr-x 1 root root 5929 Apr 10 2015 halt -rwxr-xr-x 1 root root 2001 Dec 15 23:51 htcacheclean -rwxr-xr-x 1 root root 3371 Dec 15 23:51 httpd -rwxr-xr-x 1 root root 11169 Jul 24 2015 ip6tables -rwxr-xr-x 1 root root 11048 Jul 24 2015 iptables -rwxr-xr-x 1 root root 652 Apr 10 2015 killall -rwxr-xr-x 1 root root 7026 Jun 22 2015 mysqld -rwxr-xr-x 1 root root 2989 Apr 10 2015 netconsole -rwxr-xr-x 1 root root 7570 Apr 10 2015 netfs -rwxr-xr-x 1 root root 6406 Apr 10 2015 network -rwxr-xr-x 1 root root 2795 Jun 17 2015 nginx -rwxr-xr-x 1 root root 2043 Jan 20 23:14 ntpdate -rwxr-xr-x 1 root root 2060 Jul 10 2015 php-fpm -rwxr-xr-x 1 root root 3912 Nov 10 17:59 postfix -rwxr-xr-x 1 root root 1513 Dec 11 2014 rdisc -rwxr-xr-x 1 root root 1822 Jul 24 2015 restorecond -rwxr-xr-x 1 root root 2011 Dec 10 2014 rsyslog -rwxr-xr-x 1 root root 1698 Jul 24 2015 sandbox -rwxr-xr-x 1 root root 2056 Feb 27 2015 saslauthd -rwxr-xr-x 1 root root 647 Apr 10 2015 single -rwxr-xr-x 1 root root 4621 Aug 13 17:58 sshd -rwxr-xr-x 1 root root 2294 Dec 17 01:38 udev-post //*重启各服务 /etc/init.d/nginx restart /etc/init.d/php-fpm restart /etc/init.d/mysqld restart 或者: service nginx restart service php-fpm restart service mysqld restart //** ⭐️nginx基本操作: 这里我配置了一个9090端口的访问 [root@piao conf.d]# cd /etc/nginx/conf.d [root@piao conf.d]# cat 9090.conf server { listen 9090; server_name localhost; root /data/www/piao; location / { #root /data/www/piao; index index.html index.htm index.php; } 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; } } [root@piao conf.d]# /etc/init.d/nginx reload // 重新加载上面的配置 Reloading nginx: [ OK ] 防火墙配置 [root@piao conf.d]# vi /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 9090 -j ACCEPT // 加入这行 -A INPUT -j REJECT --reject-with icmp-host-prohibited -A FORWARD -j REJECT --reject-with icmp-host-prohibited COMMIT [root@piao conf.d]# service iptables restart // 重启防火墙 ⭐️mysql基本操作: [root@piao ~]# cat /etc/my.cnf [mysqld] datadir=/var/lib/mysql // 数据库保存目录,可以修改到自定义目录 如:/data/mysql socket=/var/lib/mysql/mysql.sock user=mysql # Disabling symbolic-links is recommended to prevent assorted security risks symbolic-links=0 [mysqld_safe] log-error=/var/log/mysqld.log pid-file=/var/run/mysqld/mysqld.pid [root@piao ~]# ls -1 /var/lib/mysql/ // 查看一下数据库目录 ibdata1 ib_logfile0 ib_logfile1 mysql mysql.sock [root@piao ~]# mysql -u root -p // 用root登录 Enter password: Welcome to the MySQL monitor. Commands end with ; or \g. Your MySQL connection id is 2 Server version: 5.1.73 Source distribution Copyright (c) 2000, 2013, Oracle and/or its affiliates. All rights reserved. Oracle is a registered trademark of Oracle Corporation and/or its affiliates. Other names may be trademarks of their respective owners. Type 'help;' or '\h' for help. Type '\c' to clear the current input statement. mysql> create database piao // 创建一个名称为 piao 的数据库 -> ; Query OK, 1 row affected (0.00 sec) // 创建一个用户名为:piao 密码为:123456789 的普通用户并授权给刚刚创建的piao数据库 mysql> grant all on piao.* to 'piao'@'localhost' identified by '123456789'; mysql> exit // 退出 [root@piao ~]# ls -1 /var/lib/mysql/ ibdata1 ib_logfile0 ib_logfile1 mysql mysql.sock piao // 刚刚创建的库 [root@piao ~]# mysql -u piao -p // 用刚刚创建的用户登录测试下 Enter password: Welcome to the MySQL monitor. Commands end with ; or \g. Your MySQL connection id is 7 Server version: 5.1.73 Source distribution // 嗯,上面mysql操作完成后就可以安装bbs、blog程序了 // 添加开机启动 [root@piao conf.d]# chkconfig --add nginx [root@piao conf.d]# chkconfig nginx on [root@piao conf.d]# chkconfig --add php-fpm [root@piao conf.d]# chkconfig php-fpm on [root@piao conf.d]# chkconfig --add mysqld [root@piao conf.d]# chkconfig mysqld on [root@piao conf.d]# chkconfig --list // 查看一下启动配置 auditd 0:off 1:off 2:on 3:off 4:on 5:on 6:off crond 0:off 1:off 2:on 3:on 4:on 5:on 6:off htcacheclean 0:off 1:off 2:off 3:off 4:off 5:off 6:off httpd 0:off 1:off 2:off 3:off 4:off 5:off 6:off ip6tables 0:off 1:off 2:on 3:off 4:on 5:on 6:off iptables 0:off 1:off 2:on 3:on 4:on 5:on 6:off mysqld 0:off 1:off 2:on 3:on 4:on 5:on 6:off netconsole 0:off 1:off 2:off 3:off 4:off 5:off 6:off netfs 0:off 1:off 2:off 3:off 4:on 5:on 6:off network 0:off 1:off 2:on 3:on 4:on 5:on 6:off nginx 0:off 1:off 2:on 3:on 4:on 5:on 6:off ntpdate 0:off 1:off 2:off 3:off 4:off 5:off 6:off php-fpm 0:off 1:off 2:on 3:on 4:on 5:on 6:off postfix 0:off 1:off 2:on 3:off 4:on 5:on 6:off rdisc 0:off 1:off 2:off 3:off 4:off 5:off 6:off restorecond 0:off 1:off 2:off 3:off 4:off 5:off 6:off rsyslog 0:off 1:off 2:on 3:on 4:on 5:on 6:off saslauthd 0:off 1:off 2:off 3:off 4:off 5:off 6:off sshd 0:off 1:off 2:on 3:on 4:on 5:on 6:off udev-post 0:off 1:on 2:on 3:off 4:on 5:on 6:off [root@piao conf.d]# reboot // 重启生效 [root@piao ~]# netstat -anp // 看一下端口情况 Active Internet connections (servers and established) Proto Recv-Q Send-Q Local Address Foreign Address State PID/Program name tcp 0 0 0.0.0.0:9090 0.0.0.0:* LISTEN 1828/nginx tcp 0 0 127.0.0.1:9000 0.0.0.0:* LISTEN 1851/php-fpm tcp 0 0 0.0.0.0:3306 0.0.0.0:* LISTEN 2846/mysqld tcp 0 0 0.0.0.0:80 0.0.0.0:* LISTEN 1828/nginx
发表评论