CENTOS7 Preparing PHP

Source: Internet
Author: User
Tags fpm set time change domain name

1. Installing Apache

[1] Install httpd. [Root@linuxprobe ~]# yum-y Install httpd# Delete Default Welcome page [root@linuxprobe ~]# rm-f/etc/httpd/conf.d/welcome.conf[2] Configure HTTPD to replace the server name with your own environment [root@linuxprobe ~]# vi/etc/httpd/conf/httpd.conf# line 86: Change the administrator's email address serveradmin root@linuxprobe. org# line 95: Change domain name information servername www.linuxprobe.org:80# line 151:none becomes allallowoverride all# line 164: Add filenames that can only be accessed by using directory names DirectoryIndexIndex.htmlindex.cgiindex.php# Add follows to the end# server ' s response Header (security) Servertokens Prod# keepalive is onkeepalive on[root@linuxprobe ~]# Systemctl Start Httpd[root@linuxprobe ~]# systemctl enable Httpd[3] If FIREWALLD is running, allow HTTP service. , HTTP uses 80/tcp[root @linuxprobe ~] # firewall-cmd--add-service=http--permanentsuccess[root@ Linuxprobe ~]# firewall-cmd--reloadsuccess[4] Create an HTML test page, and use a Web browser to access it from the client PC. If the following page is displayed, it is correct [root @linuxprobe ~]# vi/var/www/html/ Index.html%; font-size:40px; font-weight:bold; text-align:center; " >welcome Access Linuxprobe.org,this is Test page!</div></body></HTML> 

    • Configure HTTPD to use PHP scripts
[1] Install PHP. [Root@linuxprobe ~]# yum-y install php php-mbstring php-pear[root @linuxprobe ~]< Span class= "hljs-comment" ># vi/etc/php.ini# Line 878: Uncomment, set time zone Date.timezone =  "Asia/shanghai" [Root @linuxprobe ~]# Systemctl restart Httpd[2] Create a PHP test page and access it from the client PC using a Web browser. If the following page is displayed, it is OK. [Root @linuxprobe ~]# vi/var/www/html/index.php "Width:100%; font-size:40px; Font-weight:bold; Text-align:center; " ><?php print Date ( "y/m/d");? ></div></body></HTML>   
    • Configure the virtual host to use multiple domain names.
      The following example is set in an environment where the domain name is [linuxprobe.org] and the virtual domain name is [virtual.host (root directory [/home/wang/public_html]].
      The settings for Userdir must be set for this example
[1] Configure the virtual host [[email protected] ~]# vi/etc/httpd/conf.d/vhost.conf# for original Domain<virtualhost *:80> documentroot/var/www/html ServerName www. linuxprobe.org</virtualhost># for Virtual Domain<virtualhost *:80> documentroot/home/cent/public_html ServerName www. virtual. host ServerAdmin [email protected].host errorlog logs/virtual.host-error_log Customlog logs/virtual.host-access_log combined</virtualhost>[[email  Protected] ~]# systemctl restart Httpd[2] Create a test page and use a Web browser to access it from the client computer. If the following page is displayed, it is correct: [[email protected] ~]$ vi ~/public_html/virtual.php3] If you don't see the page when you access the test, The following command can be used to test: [[email protected] ~]# yum-y install elinks^c[[email  Protected] ~]# elinks http://www.virtual.host/virtual.php    
&NBSP;              

2. Install PHP

1-install all these new packages:

    • Yum Install CENTOS-RELEASE-SCL
    • Yum Install rh-php56
    • Yum Install rh-php56-php
    • Yum Install Rh-php56-php-pdo
    • Yum Install Rh-php56-php-devel
    • Yum Install Rh-php56-php-mysql
    • Yum Install RH-PHP56-PHP-FPM

2-make Apache 2.4 Use PHP-FPM

Edit that file:/etc/httpd/conf.d/php.conf Put the content:

<FilesMatch \.php$>#    SetHandler application/x-httpd-php    SetHandler "proxy:fcgi://127.0.0.1:9000"</FilesMatch>

3-reboot services to handle PHP-FPM:

    • Systemctl Restart RH-PHP56-PHP-FPM
    • Systemctl Restart httpd

4-enabling rh-php56-php-fpm service on boot time

    • Systemctl Enable RH-PHP56-PHP-FPM
    • Systemctl Enable httpd

5-create a symlink for the new PHP version.

    • Mv/usr/bin/php/usr/bin/phpold
    • Ln-s/opt/rh/rh-php56/root/bin/php/usr/bin/php
ShareImprove this answer

3. Install MySQL

MARIADB is installed by default in CentOS, this is the branch of MySQL, but in order to need, it is necessary to install MySQL in the system, and after the installation is complete, you can overwrite the mariadb directly.

1 Download and install the official MySQL Yum Repository
[Email protected] ~]# Wget-i-C http://dev.mysql.com/get/mysql57-community-release-el7-10.noarch.rpm

Use the command above to download the installation of Yum Repository, about 25KB, then you can directly install Yum.

[Email protected]ost ~]# yum-y Install mysql57-community-release-el7-10.noarch.rpm

After that, the MySQL server starts to install.

[Email protected] ~]# yum-y install Mysql-community-server

This step may take some time, and the previous mariadb will be overwritten when the installation is complete.

Now that MySQL is installed, then there are some settings for MySQL.

2 MySQL Database settings

Start MySQL First

[Email protected] ~]# systemctl start  mysqld.service

View MySQL running status, running status

[Email protected] ~]# systemctl status Mysqld.service

At this point, MySQL has started to run normally, but to get into MySQL also need to find the root user's password, the following command can be found in the log file password:

[[email protected] ~]# grep "Password"/var/log/mysqld.log

Enter the database as follows:

[Email protected] ~]# mysql-uroot-p

Enter the initial password and you can't do anything at this time, because MySQL must change the password before you can manipulate the database:

Mysql> ALTER USER ' root ' @ ' localhost ' identified by ' new password ';

Here is a question, if the setting of the new password is too simple to error:

The reason for this is that MySQL has a password-setting specification, specifically related to the value of Validate_password_policy:

MySQL complete initial password rules can be viewed by the following commands:

mysql> SHOW VARIABLES like ' validate_password% '; +--------------------------------------+-------+| Variable_name                        | Value |+--------------------------------------+-------+| Validate_password_check_user_name    | OFF   | | validate_password_dictionary_file    |       | | validate_password_length             | 4     | | validate_ Password_mixed_case_count   | 1     | | validate_password_number_count       | 1     | | validate_password_policy             | Low   | | validate_password_special_char_count | 1     |+--------------------------------------+-------+7 rows In Set (0.01 sec)

The length of the password is determined by validate_password_length, while the Validate_password_length formula is:

Validate_password_length = Validate_password_number_count + Validate_password_special_char_count + (2 * validate_ Password_mixed_case_count)

Mine is already modified, the first value of the initial case is On,validate_password_length is 8. Can be modified by the following command:

Mysql> set global validate_password_policy=0;mysql> set global validate_password_length=1;

After the setting is I found above the values, at this time the password can be set up very simple, such as 1234. The password settings to this database are complete.

But at this point, there is a problem, because the Yum Repository is installed, each time the Yum operation will be automatically updated, you need to uninstall this:

[Email protected] ~]# yum-y Remove Mysql57-community-release-el7-10.noarch

After the installation is complete, start MySQL:

Authorized remote access: Log in: Use the MySQL database (real database, not database software), all permissions for all tables (*. *) of all databases (all privileges), grant the root user access through any IP (%), password 123456, Finally refresh (flush privileges).

This is really done.

4.firewall

CentOS 7.0 defaults to using firewall as the firewall, where the iptables firewall is changed.
1. Close firewall:
Systemctl Stop Firewalld.service
Systemctl Disable Firewalld.service
Systemctl Mask Firewalld.service

2. Install iptables Firewall
Yum Install Iptables-services-y

3. Start the setup Firewall

# Systemctl Enable Iptables
# Systemctl Start iptables

4. View firewall status

Systemctl status Iptables

5 edit firewall, add port
Vi/etc/sysconfig/iptables #编辑防火墙配置文件
-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
: wq! #保存退出

3. Restart the configuration, restart the system
Systemctl Restart Iptables.service #重启防火墙使配置生效
Systemctl Enable Iptables.service #设置防火墙开机启动

CENTOS7 Preparing PHP

Related Article

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.