CentOS 7.0 Server Installation configuration Lamp server (APACHE+PHP+MARIADB) _linux

Source: Internet
Author: User
Tags install php php script centos iptables

Prepare the article:

CentOS 7.0 System installation Configuration Diagram tutorial

Http://www.jb51.net/os/188487.html

First, configure the firewall, open 80 ports, 3306 ports

CentOS 7.0 uses firewall as a firewall by default, and this is iptables firewall instead.

1. Close firewall:

Systemctl Stop Firewalld.service #停止firewall
Systemctl Disable Firewalld.service #禁止firewall开机启动

2. Install iptables Firewall

Yum install iptables-services #安装
vi/etc/sysconfig/iptables #编辑防火墙配置文件
# Firewall configuration 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 Establis Hed,related-j ACCEPT
-a input-p icmp-j ACCEPT-
a input-i lo-j ACCEPT
-a input-m state--state new-m t Cp-p TCP--dport 22-j ACCEPT
-a input-m state--state new-m tcp-p TCP--dport 80-j ACCEPT
-a input-m stat E--state new-m tcp-p tcp--dport 3306-j ACCEPT
-a input-j REJECT---reject-with icmp-host-prohibited
-a FORW Ard-j REJECT--reject-with icmp-host-prohibited
COMMIT

: wq! #保存退出

Systemctl Restart Iptables.service #最后重启防火墙使配置生效
Systemctl Enable Iptables.service #设置防火墙开机启动

Second, close SELinux

Vi/etc/selinux/config
#SELINUX =enforcing #注释掉
#SELINUXTYPE =targeted #注释掉
selinux=disabled #增加

: wq! #保存退出

Setenforce 0 #使配置立即生效

Installation article:

First, install Apache

Yum Install httpd #根据提示, enter y installation to successfully install
systemctl start Httpd.service #启动apache
systemctl Stop Httpd.service # Stop the Apache
systemctl restart Httpd.service #重启apache
systemctl enable Httpd.service #设置apache开机启动

When you open the server IP address in the client browser, the following interface appears, stating that the Apache installation was successful

Second, install MARIADB

CentOS 7.0, the MySQL database has been replaced with MARIADB

1. Installation mariadb

Yum Install mariadb mariadb-server #询问是否要安装, enter Y to install automatically until the installation is complete
systemctl start Mariadb.service #启动MariaDB
Systemctl Stop Mariadb.service #停止MariaDB
systemctl restart Mariadb.service #重启MariaDB
systemctl Enable Mariadb.service #设置开机启动
cp/usr/share/mysql/my-huge.cnf/etc/my.cnf #拷贝配置文件 (Note: If the/etc directory has a my.cnf under the default, directly overwrite it)

2. Set password for root account

Mysql_secure_installation
Carriage return, enter y according to the prompt
Enter 2 times password, return
Follow the prompts to enter Y
Last seen: the for using mysql!
MARIADB password settings complete, reboot mariadb:
Systemctl Restart Mariadb.service #重启MariaDB

Third, the installation of PHP

1. Install PHP

Yum Install PHP #根据提示输入Y直到安装完成

2, the installation of PHP components, so that 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

#这里选择以上安装包进行安装, enter Y return according to the prompts

Systemctl Restart Mariadb.service #重启MariaDB

Systemctl Restart Httpd.service #重启apache

Configuration Chapter

First, Apache configuration

vi/etc/httpd/conf/httpd.conf #编辑文件
serversignature on #添加, displays the Apache version on the error page, off to show no
Options Indexes FollowSymLinks #修改为: Options Includes execcgi followsymlinks (allows the server to execute CGI and SSI, disable listing of directories)
#AddHandler cgi-script. CGI # Modified as: AddHandler cgi-script. PL (Allow CGI script with extension. pl)
allowoverride None #修改为: allowoverride All (Allow. htaccess)
adddefaultcharset UTF-8 #修改为: Adddefaultcharset GB2312 (add GB2312 to default encoding)
#Options Indexes followsymlinks  # Modify to Options FollowSymLinks (does not display the tree directory structure on the browser)
directoryindex index.html  #修改为: DirectoryIndex index.html index.htm default.html default.htm index.php (set default home file, add index.php)
maxkeepaliverequests 500 # Add maxkeepaliverequests 500 (increase number of simultaneous connections)

: wq! #保存退出

Systemctl Restart Httpd.service #重启apache

Rm-f/etc/httpd/conf.d/welcome.conf/var/www/error/noindex.html #删除默认测试页

Second, PHP configuration

Vi/etc/php.ini #编辑 Date.timezone = PRC #把前面的分号去掉, change to Date.timezone = PRC Disable_functions = passthru,exec,system,chroot,s Candir,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 #列出PHP可以禁用的函数, if some programs need to use this function, you can delete it, cancel it. expose_php = off #禁止显示php版本的信息 Short_open_tag = on #支持php短标签 Open_basedir =.:/ tmp/#设置表示允许访问当前目录 (that is, the directory where the php script files are located) and/tmp/directory, you can prevent the PHP Trojan Cross station, if you change the installation program after the problem (such as: The Dream Content Management System), you can log off this line, or directly write the directory of the program/data/www.osyunwei.com/:/tmp/ 

: wq! #保存退出

Systemctl Restart Mariadb.service #重启MariaDB
Systemctl Restart Httpd.service #重启apache

Test article

Cd/var/www/html
VI index.php #输入下面内容

<?php
phpinfo ();
? >

: wq! #保存退出

Enter the server IP address in the client browser and see the relevant configuration information as shown in the following figure!

NOTE: The Apache default program directory is/var/www/html

Permission settings: Chown apache.apache-r/var/www/html

At this point, the CentOS 7.0 installation configuration Lamp server (APACHE+PHP+MARIADB) tutorial 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.