Step #1: Install Apache on a CentOS 7 / RHEL 7 server

yum install httpd

Enable the httpd service at boot time and start it

systemctl enable httpd
systemctl start httpd

Allow external access to port 80 (http) and 443 (https).

firewall-cmd --permanent --zone=public --add-service=http 
firewall-cmd --permanent --zone=public --add-service=https
firewall-cmd --reload

At this stage, you can point your web-browser to your server’s IP address. The following page should display on screen:

snap290

Gracefully restart the httpd service on a CentOS/RHEL v7.x

sudo apachectl graceful

Test httpd/Apache configuration file for errors on a CentOS/RHEL v7.x

sudo apachectl configtest
Sample outputs:

Syntax OK

httpd service default configuration

  1. Default config file: /etc/httpd/conf/httpd.conf
  2. Configuration files which load modules : /etc/httpd/conf.modules.d/ directory (e.g. PHP)
  3. Select MPMs (Processing Model) as loadable modules [worker, prefork (default)] and event: /etc/httpd/conf.modules.d/00-mpm.conf
  4. Default ports: 80 and 443 (SSL)
  5. Default log files: /var/log/httpd/{access_log,error_log}

Step #2: Install MariaDB on a CentOS 7 / RHEL 7 server

MariaDB An enhanced, drop-in replacement for MySQL server. RHEL/CentOS v7.x shifts from MySQL to MariaDB for its database management system needs.

yum install mariadb-server mariadb

Enable the mariadb service at boot time and start it

 systemctl start mariadb
 systemctl enable mariadb

Securing MariaDB

mysql_secure_installation

Sample outputs:

NOTE: RUNNING ALL PARTS OF THIS SCRIPT IS RECOMMENDED FOR ALL MariaDB
      SERVERS IN PRODUCTION USE!  PLEASE READ EACH STEP CAREFULLY!
In order to log into MariaDB to secure it, we'll need the current
password for the root user.  If you've just installed MariaDB, and
you haven't set the root password yet, the password will be blank,
so you should just press enter here.
Enter current password for root (enter for none): PRESS-ENTER-KEY
OK, successfully used password, moving on...
Setting the root password ensures that nobody can log into the MariaDB
root user without the proper authorisation.
Set root password? [Y/n] Y
New password: YOUR-NEW-PASSWORD-HERE
Re-enter new password: YOUR-NEW-PASSWORD-HERE
Password updated successfully!
Reloading privilege tables..
 ... Success!
By default, a MariaDB installation has an anonymous user, allowing anyone
to log into MariaDB without having to have a user account created for
them.  This is intended only for testing, and to make the installation
go a bit smoother.  You should remove them before moving into a
production environment.
Remove anonymous users? [Y/n] Y
 ... Success!
Normally, root should only be allowed to connect from 'localhost'.  This
ensures that someone cannot guess at the root password from the network.
Disallow root login remotely? [Y/n] Y
 ... Success!
By default, MariaDB comes with a database named 'test' that anyone can
access.  This is also intended only for testing, and should be removed
before moving into a production environment.
Remove test database and access to it? [Y/n] Y
 - Dropping test database...
 ... Success!
 - Removing privileges on test database...
 ... Success!
Reloading the privilege tables will ensure that all changes made so far
will take effect immediately.
Reload privilege tables now? [Y/n] Y
 ... Success!
Cleaning up...
All done!  If you've completed all of the above steps, your MariaDB
installation should now be secure.
Thanks for using MariaDB!

Test login MariaDB

mysql -u root -p

Step #3: Install PHP on a CentOS/RHEL v7.x

yum install php php-mysql php-gd php-pear php-ldap php-odbc php-xml php-xmlrpc php-mbstring php-snmp php-soap curl curl-devel

You must restart the httpd (Apache) service, enter:

 systemctl restart httpd

To search all other php modules, type:
yum search php-
Sample outputs:

php-cli.x86_64 : Command-line interface for PHP
php-common.x86_64 : Common files for PHP
php-gd.x86_64 : A module for PHP applications for using the gd graphics library
php-ldap.x86_64 : A module for PHP applications that use LDAP
php-mysql.x86_64 : A module for PHP applications that use MySQL databases
php-odbc.x86_64 : A module for PHP applications that use ODBC databases
php-pdo.x86_64 : A database access abstraction module for PHP applications
php-pear.noarch : PHP Extension and Application Repository framework
php-pecl-memcache.x86_64 : Extension to work with the Memcached caching daemon
php-pgsql.x86_64 : A PostgreSQL database module for PHP
php-process.x86_64 : Modules for PHP script using system process interfaces
php-recode.x86_64 : A module for PHP applications for using the recode library
php-soap.x86_64 : A module for PHP applications that use the SOAP protocol
php-xml.x86_64 : A module for PHP applications which use XML
php-xmlrpc.x86_64 : A module for PHP applications which use the XML-RPC protocol

To find more info about a module type:
yum info php-pgsql
To install php module called php-pgsql type:
yum install php-pgsql

Test PHP on your server

Create a file called /var/www/html/test.php as follows:

 vi /var/www/html/test.php

Append the following code:

 
<?php
   phpinfo(INFO_GENERAL);
?>

Save and close the file. Point your web-browser to your server’s IP address such as http://192.168.0.64/test.php (feel free to replace the 192.168.0.64 with your actual IP address):


Sample outputs:

snap291

 

 

最後修改日期: 2016-09-17

作者

留言

撰寫回覆或留言