CentOS Yum install Apache and modify port methods

Source: Internet
Author: User

Yum installation as always convenient:

First of all:

Yum Install httpd
After the carriage return, Yum prompts the currently installed HTTPD version and automatically updates it, and installs automatically if it is not installed. Note Enter "Y" during the Yum installation to confirm the installation.
After the Apache installation completes, manually start the Apache2:

/ETC/INIT.D/HTTPD start
Then install the relevant module (lamp)

Yum install php-mysql php-gd php-imap php-ldap php-odbc php-pear php-xml php-xmlrpc
After installation reboot:

/ETC/INIT.D/HTTPD restart
Finally set boot up:

Chkconfig--levels 2345 httpd on
Chkconfig--levels 2345 mysqld on
Of course, there may be other extension modules:

Yum-y Install httpd-manual mod_ssl mod_perl mod_auth_mysql
Finally, it introduces the related configuration and environment
Apache Main configuration file:/etc/httpd/conf/httpd.conf
Apache Master configuration directory, you can classify different types of configuration into this directory:/etc/httpd/conf.d/
Apache site root directory:/var/www/html/
Apache log file directory:/VAR/LOG/HTTPD
MySQL my.cnf config file:/etc/my.cnf
MySQL database file location:/usr/lib/mysql

Open port

Vi/etc/sysconfig/iptables
-A input-m state--state new-m tcp-p TCP--dport 80-j ACCEPT # (allow 80 ports through firewalls)
-A input-m state--state new-m tcp-p TCP--dport 3306-j ACCEPT # (Allow 3306 ports through firewalls)

Change the number to the port you want to open.
Then we save the settings, and the reboot is OK.

/etc/init.d/iptables Restart #最后重启防火墙使配置生效

If you need to change the port

Because Nginx accounted for 80 port relationship, had to change Apache port to another place, location is a problem:/etc/httpd/conf/httpd.conf (CentOS)

Find the Future: Listen, to change the number, save, and then restart Apache, there is no problem, of course, the port list to open the port.

/ETC/INIT.D/HTTPD Restart # restart Apache

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.