I recently wanted to build an Alibaba Cloud LMAP environment, and I chose CentOS7 to build it. Through this article, I will share with you how to build an Apache+PHP+MySQL environment using Alibaba Cloud CentOS7. Friends who are interested should take a look together
I recently wanted to build an LMAP environment for Alibaba Cloud and chose CentOS7. Do the building.
1.Apache
Centos7 has the httpd service installed by default, but it has not been started.
If you need a new installation, you can yum install -y httpd
Start the service: systemctl start httpd.service
Set automatic startup at boot: systemctl enable httpd.service
ApacheConfiguration file:/etc/httpd/conf/httpd.conf
The default storage directory of the project is /var/www/html
You can use vi to edit or use SFTP to download and edit.
Check and open port 22 of the server: iptables -I INPUT -p tcp --dport 22 -j ACCEPT
vi /etc/httpd/conf/httpd.conf #编辑文件 ServerSignature On #添加,在错误页中显示Apache的版本,Off为不显示 Options Indexes FollowSymLinks #修改为:Options Includes ExecCGI FollowSymLinks(允许服务器执行CGI及SSI,禁止列出目录) #AddHandler cgi-script .cgi #修改为:AddHandler cgi-script .cgi .pl (允许扩展名为.pl的CGI脚本运行) AllowOverride None #修改为:AllowOverride All (允许.htaccess) AddDefaultCharset UTF-8 #修改为:AddDefaultCharset GB2312 (添加GB2312为默认编码) #Options Indexes FollowSymLinks #修改为 Options FollowSymLinks(不在浏览器上显示树状目录结构) DirectoryIndex index.html #修改为:DirectoryIndex index.html index.htm Default.html Default.htm index.php(设置默认首页文件,增加index.php) MaxKeepAliveRequests 500 #添加MaxKeepAliveRequests 500 (增加同时连接数) :wq! #保存退出 systemctl restart httpd.service #重启apache rm -f /etc/httpd/conf.d/welcome.conf /var/www/error/noindex.html #删除默认测试页
2. Installation PHP5
##Install PHP main program:yum -y install php
yum -y install php-gd php-ldap php-odbc php-pear php-xml php-xmlrpc php-mbstring php-snmp php-soap curl curl-devel
3. Install mysql
The yum source of CentOS7 does not have mysql by default. In order to solve this problem, we must first download the repo source of mysql.1. Download the mysql repo source
$ wget http://repo.mysql.com/mysql-community-release-el7-5.noarch.rpm
2. Install the mysql-community-release-el7-5.noarch.rpm package
$ sudo rpm -ivh mysql-community-release-el7-5.noarch.rpm
3. Install mysql
$ sudo yum install mysql-server
4. Reset password
Before resetting the password, you must first log in$ mysql -u root
$ sudo chown -R root:root /var/lib/mysql
$ service mysqld restart
$ mysql -u root mysql > use mysql; mysql > update user set password=password(‘123456‘) where user=‘root‘; mysql > exit;
5. Open port 3306
$ sudo vim /etc/sysconfig/iptables
-A INPUT -p tcp -m state --state NEW -m tcp --dport 3306 -j ACCEPT
$ sudo service iptables restart
linux Under phpMyAdmin, "mysqli extension is missing, please check the PHP configuration."
Cause: the mysqli extension is not installed, or you did not add extension=mysqli.d to php.ini##Solution: yum install php-mysql Then restart apache
Package project tar -zcvf /home/files.tar.gz /files Packaging
Unzip tar -xzvf files.tar.gz
The above is the detailed content of Detailed introduction to building Apache+PHP+MySQL environment on Alibaba Cloud CentOS7. For more information, please follow other related articles on the PHP Chinese website!