When you have a new VPS installed CentOS to use as web server, you need install some basic packets as apache, mysql, php and setup web server. You will ask yourself that how to install php web server on CentOS? So I will show you steps to implement it as the below.
Installing httpd:
1 2 |
sudo yum install httpd sudo service httpd start |
Make sure that you have root permission
Install mysql server:
1 2 |
sudo yum install mysql-server sudo service mysqld start |
Installing PHP:
1 |
sudo yum install php php-mysql |
Now, we will setup web server for new domain that was pointed to the ip address of new VPS.
Create web directory:
1 |
mkdir -p /var/www/example.com/public_html |
Create a test file:
1 |
sudo vi /var/www/example.com/public_html/index.html |
Open httpd.config file:
1 |
sudo vi /etc/httpd/conf/httpd.conf |
Add lines below to the bottom of httpd.conf file:
1 2 3 4 5 6 7 8 9 |
NameVirtualHost *:80 <VirtualHost *:80> ServerAdmin webmaster@example.com DocumentRoot /var/www/example.com/public_html ServerName example.com ServerAlias example.com ErrorLog /var/www/example.com/error.log CustomLog /var/www/example.com/requests.log common </VirtualHost> |
Check iptables firewall to make sure that port 80 is opened:
1 |
sudo service iptables status |
Or open port 80 if needed:
1 |
sudo iptables -I INPUT 1 -p tcp --dport 80 -j ACCEPT |
So now, you can access your website example.com.