Install the configuration Lamp Server (APACHE+PHP+MARIADB) RHEL 7.0 in a Linux system

Source: Internet
Author: User
Tags gpg install php php script iptables
Prepare the article:

RHEL 7.0 System installation Configuration Diagram Tutorial I'm not going to introduce you here.

Configuring a local Yum source with a system-mirrored file

1, using WinSCP.exe and other tools upload system image files Rhel-server-7.0-x86_64-dvd.iso to/usr/local/src directory
2. Connect to Rhel server remotely using Putty.exe tool
3. Mount System image files
Mkdir/media/cdrom #新建镜像文件挂载目录
CD/USR/LOCAL/SRC #进入系统镜像文件存放目录
LS #列出目录文件, you can see the system image file just uploaded
Mount-t Iso9660-o Loop/usr/local/src/rhel-server-7.0-x86_64-dvd.iso/media/cdrom #挂载系统镜像
Cd/media/cdrom #进入挂载目录, use the LS command to see that a file exists
Note: Umount/media/cdrom #卸载系统镜像
4, set up automatically mounted system image files
Vi/etc/fstab #添加以下代码. Enable automatic mount on boot
/usr/local/src/rhel-server-7.0-x86_64-dvd.iso/media/cdrom iso9660 defaults,ro,loop 0 0
: wq! #保存退出
Note: iso9660 use df-t to view
5. Configure local Yum Source
Cd/etc/yum.repos.d/#进入yum配置目录
Touch Rhel-media.repo #建立yum配置文件
VI Rhel-media.repo #编辑配置文件, add the following
[Rhel-media]
name=red Hat Enterprise Linux 7.0 #自定义名称
Baseurl=file:///media/cdrom #本地光盘挂载路径
Enabled=1 #启用yum源, 0 is not enabled, 1 is enabled
Gpgcheck=1 #检查GPG-key,0 for no check, 1 for inspection
Gpgkey=file:///media/cdrom/rpm-gpg-key-redhat-release #GPG-key Path
: wq! #保存退出
6. Configure Yum command
Yum Clean all #清除yum缓存
Yum Makecache #缓存本地yum源中的软件包信息
You can now install the software automatically using the Yum command.
Second, configure the firewall, open 80 ports, 3306 ports
RHEL 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 Firewalld.service #最后重启防火墙使配置生效
Third, 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 install successfully
Systemctl Start Httpd.service #启动apache
Systemctl Stop Httpd.service #停止apache
Systemctl Restart Httpd.service #重启apache
Systemctl Enable Httpd.service #设置apache开机启动
Second, install MARIADB
RHEL 7.0, the MySQL database has been replaced with MARIADB
1. Installation mariadb
System Yun-wei www.osyunwei.com warm reminder: qihang01 original Content © Copyright, reproduced please indicate the source and the original chain
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 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
System Yun-wei www.osyunwei.com warm reminder: qihang01 original Content © Copyright, reproduced please indicate the source and the original chain
Yum install php-mysql php-gd libjpeg* php-ldap php-odbc php-pear php-xml php-xmlrpc Php-mhash
#这里选择以上安装包进行安装, enter Y return according to the prompts
Systemctl Restart Mariadb.service #重启MariaDB
Systemctl Restart Httpd.service #重启apache
Configuration article:
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.htm index.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版本的信息
MAGIC_QUOTES_GPC = on #打开magic_quotes_gpc来防止SQL注入
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.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!
If the page doesn't open, make sure the FIREWALLD firewall is turned off
Systemctl Stop Firewalld.service #停止firewall
Systemctl Disable Firewalld.service #禁止firewall开机启动
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.