CentOS 7.0 uses firewall as the firewall by default, here is changed to iptables firewall.
1、 Close the firewall:
systemctl stop firewalld.service #Stop firewall
systemctl disable firewalld.service #Prohibit firewall from booting up
2、 Install iptables firewall
yum install iptables-services #install
vi /etc/sysconfig/iptables #Edit firewall configuration file
: 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
: wq! #Save and exit
systemctl restart iptables.service #Finally restart the firewall to make the configuration effective
systemctl enable iptables.service #Set the firewall to start up
Second, close SELINUX
vi /etc/selinux/config
SELINUX=disabled #increase
: wq! #Save and exit
setenforce 0 #Make the configuration effective immediately
**Installation articles: **
One, install Apache
System operation and maintenance www.111cn.net Warm reminder: qihang01 original content © copyright, reprint please indicate the source and the original link
yum install httpd #According to the prompt, enter Y to install to successfully install
systemctl start httpd.service #Start apache
systemctl stop httpd.service #stop apache
systemctl restart httpd.service #Restart apache
systemctl enable httpd.service #Set apache to start up
Open the server IP address in the client browser, the following interface will appear, indicating that the apache installation is successful
System operation and maintenance www.111cn.net Warm reminder: qihang01 original content © copyright, reprint please indicate the source and the original link
In CentOS 7.0, MariaDB has been used instead of MySQLdatabase
1、 Install MariaDB
yum install mariadb mariadb-server # Ask if you want to install, enter Y to install automatically until the installation is complete
systemctl start mariadb.service #Start MariaDB
systemctl stop mariadb.service #Stop MariaDB
systemctl restart mariadb.service #Restart MariaDB
systemctl enable mariadb.service #Set boot up
cp /usr/share/mysql/my-huge.cnf /etc/my.cnf #copy the configuration file (note: if there is a my.cnf in the /etc directory by default, just overwrite it)
2、 Set a password for the root account
mysql_secure_installation
Press Enter and enter Y according to the prompt
Enter the password twice and press Enter
Enter Y according to the prompt
Finally appeared: Thanks for using MySQL!
MySql password setting is complete, restart MySQL:
systemctl restart mariadb.service #Restart MariaDB
Three, install PHP
1、 Install PHP
yum install php #Enter Y according to the prompt until the installation is complete
2、 Install PHP components to make PHP support MariaDB
yum install php-mysql php-gd libjpeg* php-ldap php-odbc php-pear php-xml php-xmlrpc php-mbstring php-bcmath php-mhash
systemctl restart mariadb.service #Restart MariaDB
systemctl restart httpd.service #Restart apache
Configuration article
One, Apache configuration
vi /etc/httpd/conf/httpd.conf #Edit file
ServerSignature On #Add, display the version of Apache in the error page, Off is not displayed
Options Indexes FollowSymLinks #Modified to: Options Includes ExecCGI FollowSymLinks (allow the server to execute CGI and SSI, prohibit listing directories)
AllowOverride None #Modify to: AllowOverride All (allow .htaccess)
AddDefaultCharset UTF-8 #Modify to: AddDefaultCharset GB2312 (add GB2312 as the default encoding)
DirectoryIndex index.html #Modify to: DirectoryIndex index.html index.htm Default.html Default.htmindex.php (set the default home page file, increase index.php)
MaxKeepAliveRequests 500 #Add MaxKeepAliveRequests 500 (increase the number of simultaneous connections)
: wq! #Save and exit
systemctl restart httpd.service #Restart apache
rm -f /etc/httpd/conf.d/welcome.conf /var/www/error/noindex.html #Delete the default test page
vi /etc/php.ini #Edit
date.timezone = PRC #Remove the semicolon in front and change to date.timezone = PRC
disable_functions = passthru,exec,system,chroot,scandir,chgrp,chown,shell_exec,proc_open,proc_get_status,ini_alter,ini_alter,ini_restore,dl,openlog,syslog,readlink,symlink,popepassthru,stream_socket_server,escapeshellcmd,dll,popen,disk_free_space,checkdnsrr,checkdnsrr,getservbyname,getservbyport,disk_total_space,posix_ctermid,posix_get_last_error,posix_getcwd, posix_getegid,posix_geteuid,posix_getgid, posix_getgrgid,posix_getgrnam,posix_getgroups,posix_getlogin,posix_getpgid,posix_getpgrp,posix_getpid, posix_getppid,posix_getpwnam,posix_getpwuid, posix_getrlimit, posix_getsid,posix_getuid,posix_isatty, posix_kill,posix_mkfifo,posix_setegid,posix_seteuid,posix_setgid, posix_setpgid,posix_setsid,posix_setuid,posix_strerror,posix_times,posix_ttyname,posix_uname
expose_php = Off #Prohibit displaying php version information
short_open_tag = ON #Support php short tag
open_basedir = .:/tmp/ #Setting means to allow access to the current directory (that is, the directory where the PHP script file is located) and the /tmp/ directory, which can prevent the PHP Trojan from cross-site, if there is a problem with the installation program after the change (for example: weaving dream Management system), you can cancel this line, or write directly into the program directory /data/www.111cn.net/:/tmp/
: wq! #Save and exit
systemctl restart mariadb.service #Restart MariaDB
systemctl restart httpd.service #Restart apache
Test articles
cd /var/www/html
vi index.php #Enter the following
php phpinfo(); ?>: wq! #Save and exit
Enter the server IP address in the client browser, you can see the related configuration information as shown in the figure below!
Note: The default program directory of apache is /var/www/html
Permission setting: chown apache.apache -R /var/www/html
( adsbygoogle = window.adsbygoogle || []).push({});
Recommended Posts