CentOS7.0 install and configure the LAMP server (Apache + PHP + MariaDB) _ MySQL

Source: Internet
Author: User
CentOS7.0 install and configure the LAMP server (Apache + PHP + MariaDB) MariaDBCentOSApacheLAMP

Preparation:

CentOS 7.0 system installation and configuration graphic tutorial

Http://www.osyunwei.com/archives/7829.html

1. configure the firewall and enable port 80 and Port 3306

CentOS 7.0 uses firewall as the firewall by default. here, it is changed to iptables firewall.

1. disable firewall:

Systemctl stop firewalld. service # stop firewall

Systemctl disable firewalld. service # disable firewall startup

2. install iptables firewall

Yum install iptables-services # installation

Vi/etc/sysconfig/iptables # Edit the firewall configuration file

# 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

: Wq! # Save and exit

Systemctl restart firewalld. service # restart the firewall to make the configuration take effect.

Systemctl enable firewalld. service # set firewall startup

II. disable SELINUX

Vi/etc/selinux/config

# SELINUX = enforcing # Comment out

# SELINUXTYPE = targeted # Comment out

SELINUX = disabled # Add

: Wq! # Save and exit

Setenforce 0 # Make the configuration take effect immediately

Installation:

1. install Apache

System O & M www.osyunwei.com reminder: qihang01 original content©Copyright. For more information, see the source and source text chain.

Yum install httpd # enter Y as prompted to install httpd.

Systemctl start httpd. service # start apache

Systemctl stop httpd. service # stop apache

Systemctl restart httpd. service # restart apache

Systemctl enable httpd. service # set apache startup

Open the server IP address in the client browser. the following interface is displayed, indicating that apache is successfully installed.

System O & M www.osyunwei.com reminder: qihang01 original content©Copyright. For more information, see the source and source text chain.

II. install MariaDB

In CentOS 7.0, MariaDB has been used to replace the MySQL database.

1. install MariaDB

Yum install mariadb-server # ask if you want to install mariadb. enter Y to install mariadb automatically until 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 startup

Cp/usr/share/mysql/my-huge.cnf/etc/my. cnf # Copy the configuration file (note: If there is a my. cnf under the/etc directory by default, directly overwrite it)

2. set a password for the root account

Mysql_secure_installation

Press enter and enter Y as prompted.

Enter the password twice and press enter.

Enter Y as prompted

Thanks for using MySQL!

After setting the MySql password, restart MySQL:

Systemctl restart mariadb. service # restart MariaDB

3. install PHP

1. install PHP

Yum install php # enter Y as prompted until installation is complete

2. install the PHP component so that PHP supports MariaDB

Yum install php-mysql php-gd libjpeg * php-ldap php-odbc php-pear php-xml php-xmlrpc php-mbstring php-bcmath php-mhash

# Select the preceding installation package for installation. enter Y and press enter as prompted.

Systemctl restart mariadb. service # restart MariaDB

Systemctl restart httpd. service # restart apache

Configuration

1. Apache configuration

Vi/etc/httpd/conf/httpd. conf # edit the file

ServerSignature On # add, the Apache version is displayed On the error page, and Off is not displayed

Options Indexes FollowSymLinks # changed to: Options shortdes ExecCGI FollowSymLinks (allows the server to execute CGI and SSI, and prohibits the list of directories)

# AddHandler cgi-script. cgi # modify it to AddHandler cgi-script. cgi. pl (run a CGI script with the extension. pl)

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

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

# Options Indexes FollowSymLinks # Change to Options FollowSymLinks (the tree directory structure is not displayed in the browser)

DirectoryIndex index.html # changed to: DirectoryIndex index.html index.htm Default.html Default.htm index. php (set the default homepage file and add 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

II. php configuration

Vi/etc/php. ini # Edit

Date. timezone = PRC # Remove the semicolon and change it to date. timezone = PRC.

Disable_functions = passthru, exec, system, chroot, scandir, chgrp, chown, shell_exec, proc_open, proc_get_status, ini_alter, ini_alter, disconnect, dl, openlog, syslog, readlink, symlink, release, delimiter, delimiter, dll, popen, disk_free_space, checkdnsrr, checkdnsrr, getservbyname, getservbyport, delimiter, posix_getgrnam, posix_getgroups, posix_getlogin, delimiter, delimiter, posix_getpid, delimiter, delimiter, posix_getpwuid, delimiter, posix_getsid, posix_getuid, delimiter, posix_kill, posix_mkfifo, delimiter, posix_setsid, posix_setuid, posix_strerror, posix_times, posix_ttyname, posix_uname

# List functions that can be disabled by PHP. if some programs need this function, they can be deleted and disabled.

Expose_php = Off # Disable Display of php version information

Short_open_tag = ON # php short labels supported

Open_basedir =. :/tmp/# set to allow access to the current directory (that is, the directory where the PHP script file is located) and/tmp/directory, which can prevent php Trojans from being cross-site, if there is a problem with the installation program after the change (for example, Zhimeng content management system), you can log out of this line or directly write the program directory/data/www.osyunwei.com/:/tmp/

: Wq! # Save and exit

Systemctl restart mariadb. service # restart MariaDB

Systemctl restart httpd. service # restart apache

Test

Cd/var/www/html

Vi index. php # enter the following content

Phpinfo ();

?>

: Wq! # Save and exit

Enter the server IP address in the browser of the client. the configuration information shown in is displayed!

Note: the default program directory of apache is/var/www/html.

Permission settings: chown apache. apache-R/var/www/html

Now, the installation and configuration of the LAMP server (Apache + PHP + MariaDB) in CentOS 7.0 is complete!

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.