CentOS 7.0 System installation Configuration Lamp Server (APACHE+PHP+MARIADB)

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

CENTOS7 Installation Configuration Tutorial: http://www.111cn.net/sys/CentOS/63645.htm

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 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! #保存退出
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
System Yun-wei Www.111cn.net warm reminder: qihang01 original Content © Copyright, reproduced please indicate the source and the original chain
Yum Install httpd #根据提示, enter y installation to install successfully
Systemctl Start Httpd.service #启动apache
Systemctl Stop Httpd.service #停止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
System Yun-wei Www.111cn.net warm reminder: qihang01 original Content © Copyright, reproduced please indicate the source and the original chain
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, direct coverage can be)
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!
MySQL password settings complete, restart MySQL:
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 #添加, show Apache version on error page, off not show
Options Indexes followsymlinks #修改为: Options Includes execcgi followsymlinks (allows the server to execute CGI and SSI, disable listing of directories)
#AddHandler cgi-script. CGI #修改为: AddHandler cgi-script. PL (CGI script that allows the extension. pl to run)
AllowOverride None #修改为: allowoverride All (Allow. htaccess)
Adddefaultcharset UTF-8 #修改为: Adddefaultcharset GB2312 (add GB2312 to default encoding)
#Options Indexes followsymlinks #修改为 Options followsymlinks (does not display the tree directory structure on the browser)
DirectoryIndex index.html #修改为: DirectoryIndex index.html index.htm default.html Default.htmindex.php (set default first file, add index.php)
Maxkeepaliverequests #添加MaxKeepAliveRequests 500 (Increased 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,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
#列出PHP可以禁用的函数, if some programs need to use this function, you can remove it and disable it.
expose_php = Off #禁止显示php版本的信息
Short_open_tag = on #支持php短标签
Open_basedir =.:/ tmp/#设置表示允许访问当前目录 (that is, the directory of PHP script files) and the/tmp/directory, you can prevent the PHP Trojan Cross station, if the installer has problems after the change (such as: The Dream Content Management System), you can log off this line, or directly write the directory of the program/data/ www.111cn.net/:/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

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.