一、防火墙配置
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 |
vim /etc/sysconfig/iptables #编辑防火墙文件开启80、3306端口 # 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 /etc/init.d/iptables restart #重启防火墙使配置立即生效 |
二、关闭SELINUX
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 |
vim /etc/selinux/config # This file controls the state of SELinux on the system. # SELINUX= can take one of these three values: # enforcing - SELinux security policy is enforced. # permissive - SELinux prints warnings instead of enforcing. # disabled - No SELinux policy is loaded. #SELINUX=enforcing #注释掉 # SELINUXTYPE= can take one of these two values: # targeted - Targeted processes are protected, # mls - Multi Level Security protection. #SELINUXTYPE=targeted #注释掉 SELINUX=disabled #增加 setenforce 0 #使配置立即生效 |
三、安装nginx
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 |
yum install pcre pcre-devel -y yum install openssl openssl-devel -y cd /usr/local/src/ wget http://nginx.org/download/nginx-1.12.0.tar.gz useradd nginx -s /sbin/nologin -M tar xf nginx-1.12.0.tar.gz cd nginx-1.12.0 ./configure --user=nginx --group=nginx --prefix=/usr/local/nginx --with-http_stub_status_module --with-http_ssl_module make && make install /usr/local/nginx/sbin/nginx -t /usr/local/nginx/sbin/nginx lsof -i :80 COMMAND PID USER FD TYPE DEVICE SIZE/OFF NODE NAME nginx 28323 root 6u IPv4 41707 0t0 TCP *:http (LISTEN) nginx 28324 nginx 6u IPv4 41707 0t0 TCP *:http (LISTEN) |
设置nginx开机启动
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 |
vim /etc/init.d/nginx #编辑启动脚本 #!/bin/bash ######################################################################### # File Name: nginx # Author: gougui # Mail: 1105576170@qq.com # Web: http://www.igougui.com # Version: V1.0 # Description: Startup script for nginx webserver # Created Time: Tue 20 Jun 2017 02:10:12 AM CST ######################################################################### # chkconfig: 2345 55 25 ### BEGIN INIT INFO # Provides: nginx # Required-Start: $all # Required-Stop: $all # Default-Start: 2 3 4 5 # Default-Stop: 0 1 6 # Short-Description: starts the nginx web server # Description: starts nginx using start-stop-daemon ### END INIT INFO PATH=/usr/local/sbin:/usr/local/bin:/sbin:/bin:/usr/sbin:/usr/bin NAME=nginx NGINX_BIN=/usr/local/nginx/sbin/$NAME CONFIGFILE=/usr/local/nginx/conf/$NAME.conf PIDFILE=/usr/local/nginx/logs/$NAME.pid case "$1" in start) echo -n "Starting $NAME... " if netstat -tnpl | grep -q nginx;then echo "$NAME (pid `pidof $NAME`) already running." exit 1 fi $NGINX_BIN -c $CONFIGFILE if [ "$?" != 0 ] ; then echo " failed" exit 1 else echo " done" fi ;; stop) echo -n "Stoping $NAME... " if ! netstat -tnpl | grep -q nginx; then echo "$NAME is not running." exit 1 fi $NGINX_BIN -s stop if [ "$?" != 0 ] ; then echo " failed. Use force-quit" exit 1 else echo " done" fi ;; status) if netstat -tnpl | grep -q nginx; then PID=`pidof nginx` echo "$NAME (pid $PID) is running..." else echo "$NAME is stopped" exit 0 fi ;; force-quit) echo -n "Terminating $NAME... " if ! netstat -tnpl | grep -q nginx; then echo "$NAME is not running." exit 1 fi kill `pidof $NAME` if [ "$?" != 0 ] ; then echo " failed" exit 1 else echo " done" fi ;; restart) $0 stop sleep 1 $0 start ;; reload) echo -n "Reload service $NAME... " if netstat -tnpl | grep -q nginx; then $NGINX_BIN -s reload echo " done" else echo "$NAME is not running, can't reload." exit 1 fi ;; configtest) echo -n "Test $NAME configure files... " $NGINX_BIN -t ;; *) echo "Usage: $0 {start|stop|force-quit|restart|reload|status|configtest}" exit 1 ;; esac |
1 2 3 4 |
chmod +x /etc/init.d/nginx chkconfig nginx on /etc/init.d/nginx restart curl 192.168.1.106 |
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 |
<!DOCTYPE html> <html> <head> <title>Welcome to nginx!</title> <style> body { width: 35em; margin: 0 auto; font-family: Tahoma, Verdana, Arial, sans-serif; } </style> </head> <body> <h1>Welcome to nginx!</h1> <p>If you see this page, the nginx web server is successfully installed and working. Further configuration is required.</p> <p>For online documentation and support please refer to <a href="http://nginx.org/">nginx.org</a>.<br/> Commercial support is available at <a href="http://nginx.com/">nginx.com</a>.</p> <p><em>Thank you for using nginx.</em></p> </body> </html> |
四、安装Mysql
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 |
yum install gcc gcc-c++ ncurses-devel perl -y yum install cmake -y yum -y install gcc gcc-c++ gcc-g77 perl make cmake bison ncurses-devel autoconf automake zlib* fiex* libxml* &nbsp;libmcrypt* libtool-ltdl-devel* libaio libaio-devel bzr libtool ncurses5-devel imake libxml2-devel expat-devel useradd&nbsp;&nbsp;mysql -s /sbin/nologin -M mkdir -p /usr/local/mysql mkdir -p /usr/local/mysql/data chown -R mysql.mysql /usr/local/mysql cd /usr/local/src/ wget https://nchc.dl.sourceforge.net/project/boost/boost/1.59.0/boost_1_59_0.tar.gz tar -zxvf boost_1_59_0.tar.gz cd boost_1_59_0 ./bootstrap.sh ./b2 ./b2 install cd .. wget https://cdn.mysql.com//Downloads/MySQL-5.7/mysql-5.7.18.tar.gz tar -zxvf mysql-5.7.18.tar.gz cd mysql-5.7.18 cmake -DCMAKE_INSTALL_PREFIX=/usr/local/mysql \ -DMYSQL_UNIX_ADDR=/usr/local/mysql/mysql.sock \ -DMYSQL_DATADIR=/usr/local/mysql/mydata \ -DSYSCONFDIR=/etc \ -DEXTRA_CHARSETS=all \ -DDEFAULT_CHARSET=utf8 \ -DDEFAULT_COLLATION=utf8_general_ci \ -DWITH_MYISAM_STORAGE_ENGINE=1 \ -DWITH_INNOBASE_STORAGE_ENGINE=1 \ -DWITH_MEMORY_STORAGE_ENGINE=1 \ -DWITH_READLINE=1 \ -DMYSQL_TCP_PORT=3306 \ -DENABLED_LOCAL_INFILE=1 \ -DWITH_PARTITION_STORAGE_ENGINE=1 \ -DWITH_SSL=yes \ -DWITH_BOOST=/usr/local/src/boost_1_59_0 \ -DMYSQL_USER=mysql make && make install cd /usr/local/mysql/bin ./mysqld --initialize --user=mysql --datadir=/usr/local/mysql/data/ --basedir=/usr/local/mysql --socket=/usr/local/mysql/mysql.sock #运行后最后一句[note] 生成了一个mysql默认密码,复制到一个地方,保存下来。 cp /usr/local/mysql/support-files/my-default.cnf /usr/local/mysql/my.cnf ln -s /usr/local/mysql/my.cnf /etc/my.cnf cp /usr/local/mysql/support-files/mysql.server /etc/init.d/mysql chmod +x /etc/init.d/mysql chkconfig mysql on |
五、安装PHP
1 2 |
cd /usr/local/src wget http://cn2.php.net/distributions/php-7.1.6.tar.gz |