Centos7 uses yum to install Apache, mariadb, PHP

  1. Configure the firewall, open port 80 and port 3306

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

Firewall configuration written by system-config-firewall

Manual customization of this file is not recommended.

: INPUT ACCEPT [0:0]

: FORWARD ACCEPT [0:0]

: OUTPUT ACCEPT [0:0]

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=enforcing #Comment out

SELINUXTYPE=targeted #Comment out

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

  1. Install MariaDB

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

Here select the above installation package to install, and enter Y according to the prompt.

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)

AddHandler cgi-script .cgi #Modify to: AddHandler cgi-script .cgi .pl (allowing CGI scripts with extension .pl to run)

AllowOverride None #Modify to: AllowOverride All (allow .htaccess)

AddDefaultCharset UTF-8 #Modify to: AddDefaultCharset GB2312 (add GB2312 as the default encoding)

Options Indexes FollowSymLinks #Modify to Options FollowSymLinks (do not display the tree-like directory structure on the browser)

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

  1. php configuration

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

List the functions that PHP can disable. If some programs need to use this function, you can delete and cancel the disable.

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

: 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

Centos7 uses yum to install Apache, mariadb, PHP
Centos7 YUM install MariaDB 10.0
CentOS yum install Apache + PHP + Tomcat7 + MySQL
Centos7 YUM install MariaDB 10.0
Centos8 uses yum to install mongodb 4.2 method
Centos7 uses yum to install pip, ipython
CentOS 7 yum install PHP7.3 tutorial
How to install PHP7.4 in CentOS
How to install MariaDB on CentOS 8
How to install Apache on CentOS 8
How to install PHP on CentOS 8
CentOS 7.2 install MariaDB
CentOS install PHP
How to install Apache Maven on CentOS 8
How to install Apache Kafka on CentOS 7
Centos8 use yum to install rabbitmq tutorial
CentOS7 system yum way to install MySQL5.7
Centos8 uses Apache httpd2.4.37 to install web server steps in detail
Install php in centos
CentOS 7.2 Yum install MySQL 5.6
How to install php7.3 in centos8 custom directory
Install MariaDB under MariaDB Centos7
CentOS 5 to CentOS 5.8 YUM source
Centos7 uses Ansible to install Chinese fonts in batches
Install PHP in yum under CentOS, configure php-fpm service
Centos compile and install LAMP (apache-2.4.7 + mysql-5.5.35 + php 5.5.8) + Redis
centos install mysql through yum
Centos7.6 method to install Tomcat-8.5.39
How to install jdk1.8 on centOS7
CentOS7 yum install and start mysql
CentOS Yum compile and install MySQL 5.6
How to install Memcached on CentOS 8
How to install R on CentOS 8
How to install FFmpeg on CentOS 8
How to install Apache on Ubuntu 20.04
How to install TensorFlow on CentOS 8
[Introduction to redis] Install redis under Centos
CentOS 7 install Nginx, PHP, MySQL packages
How to install Perl 5 on CentOS
How to install Git on CentOS 8
How to install Gradle on CentOS 8
How to install Elasticsearch on CentOS 8
How to install Jenkins on CentOS 8
How to install Java on CentOS 8
How to install Go on CentOS 8
How to install GCC on CentOS 8
How to install Yarn on CentOS 8
Install java in yum mode in Centos
rhel7.2 yum uses CentOS update package
How to install Nginx on CentOS 8
How to install Asterisk on CentOS 7
How to install Jenkins on CentOS 8
How to install Vagrant on CentOS 8
How to install Python 3.8 on CentOS 8
How to install Tomcat 9 on CentOS 8
How to install Webmin on CentOS 8
CentOS7 yum install and start mysql
Centos yum install mysql5.6 or above
How to install Ruby on CentOS 8
How to install Apache on Ubuntu 20.04
How to install Skype on CentOS 8