Build the LAMP platform environment under Centos7,

Source: Internet
Author: User
Tags php server

Build a LAMP platform environment under Centos7 (reproduced ),
 1. Enable Apache (httpd)

By default, Centos7 has installed the httpd service, but it is not started. If you need a new installation, you can run yum install-y httpd.

Start service: systemctl start httpd. service

Set automatic start upon startup: systemctl enable httpd. service

The HTTP server has been started. perform a simple configuration.

Vi/etc/httpd/conf/httpd. conf# Editing files

# Add: the Apache version is displayed on the error page. If it is Off, It is not displayed. 

ServerSignature On

# Modify to: Options shortdes ExecCGI FollowSymLinks (allows the server to execute CGI and SSI, and prohibits the server from listing Directories) 

Options Indexes FollowSymLinks

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

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

Adddefacharcharset UTF-8# Modify it to adddefacharcharset GB2312 (add GB2312 as the default encoding)

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

DirectoryIndex index.html# Modify it 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 (increasing 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

2. Set firewall

The firewall under Centos7 has been changed from iptables to firewall. Use the firewall-cmd command to open ports 80 and 443:

Firewall-cmd-permanent-zone = public-add-service = http

Firewall-cmd-permanent-zone = public-add-service = https

Firewall-cmd-reload

Set SELinux to permissive mode. In command line, setenforce 0 takes effect immediately and the restart fails.

Edit vim/etc/sysconfig/selinux SELinux = enforcing and change it to disabled to disable SELinux. the restart takes effect permanently.

The ip address of the author is 192.168.1.108. test whether the server can be opened. The browser http: // 192.168.1.108 returns the welcome page, indicating that the server runs normally.

3. Install the MariaDB Database

In CentOS 7.0, MariaDB has already been used to replace the MySQL database. As you know, after MYSQL is acquired by Oracle, the prospects are worrying. So MariaDB, the MYSQL brother, has come out and continues the open-source business.

Install: yum-y install mariadb-server mariadb

Start: systemctl start mariadb. service

Systemctl enable mariadb. service

Configuration: cp/usr/share/mysql/my-huge.cnf/etc/my. cnf overwrite the original configuration.

Set the database administrator password: mysql_secure_installation all the way to y. Of course, enter the password twice after the first time y.

4. Install PHP5

Install the main PHP program: yum-y install php

Install the PHP component so that PHP supports MariaDB

Yum-y install php-gd php-ldap php-odbc php-pear php-xml php-xmlrpc php-mbstring php-snmp php-soap curl-devel

Restart: systemctl restart httpd. service

Configuration: vi/etc/php. ini

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

Disable_functions = passthru, exec, system ......# 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# Support for php short labels

Open_basedir =.:/tmp/# The setting indicates that access to the current directory (that is, the directory where the PHP script file is located) and the/tmp/directory can prevent php trojans from being cross-site. If there is a problem with the installation program (for example: dream Management System), you can log out of this line, or directly write the program directory/data/www.osyunwei.com/:/tmp/

Test: vi/var/www/html/index. php input <? Php phpinfo ();?> Wq is saved and exited. Open http: // 192.168.1.108. If you can see the PHP configuration page, the PHP server is normal.

Now, the LAMP platform has been set up. You can set up the Worldpress website on it. Of course, if you think it is troublesome to manage the database, you can also use yum install phpMyAdmin to install the graphical management tool.

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.