Tag Archives: Apache

Installing & Configuring Apache On Your Dedicated Server

Before installing PHP or MySQL, the first thing you need to do is install Apache on your dedicated server. In order to do that you simply need to access the command line of your server and log in as the root user:

  1. Connect your server via SSH
  2. Run this command: sudo su –
  3. Enter your server password

You now have root access.

Once you have that, you can install Apache using the ‘Yum‘ command:

[root@admin]# yum install httpd
Loaded plugins: fastestmirror, langpacks
base
| 3.6 kB 00:00:00
extras
| 3.4 kB 00:00:00
updates
| 3.4 kB 00:00:00
extras/7/x86_64/primary_d
| 121 kB 00:00:00
Loading mirror speeds from cached hostfile
* base: mirror.sigmanet.com
* extras: linux.mirrors.es.net
* updates: mirror.eboundhost.com
Resolving Dependencies
--> Running transaction check
---> Package httpd.x86_64 0:2.4.6-45.el7.centos will be installed
--> Processing Dependency: httpd-tools = 2.4.6-45.el7.centos for package:
httpd-2.4.6-45.el7.centos.x86_64
--> Processing Dependency: /etc/mime.types for package: httpd-2.4.645.el7.centos.x86_64
--> Running transaction check
---> Package httpd-tools.x86_64 0:2.4.6-45.el7.centos will be installed
---> Package mailcap.noarch 0:2.1.41-2.el7 will be installed
--> Finished Dependency Resolution
Installed:
httpd.x86_64 0:2.4.6-45.el7.centos

Dependency Installed:
httpd-tools.x86_64 0:2.4.6-45.el7.centos
mailcap.noarch 0:2.1.41-2.el7

Complete!
[root@admin]#

Once Apache is installed, the next thing you need to do is configure it and then make sure it works on your server, use the following command:

[root@admin]# systemctl start httpd && systemctl enable httpd

To make sure the Apache services are running on your server:

[root@admin] sudo systemctl status httpd

This will show you an active status if the service is running on your dedicated server.

Managing Apache & PHP Modules On Your Server

You can install necessary PHP modules for Apache on your VPS and Dedicated Server and then enable them manually.

You can enable, disable, or customize such modules using a tool called EasyApache. By using this tool, the PHP and Apache options are rebuilt on the basis of the options you select.

  1. Login to your SANGKRIT.net account
  2. Visit your My Products page
  3. Click the Servers option
  4. Click Manage
  5. Open WHM

The easiest way to upgrade PHP is through EasyApace which you can find in the software section of WHM:

  1. Lookup for EasyApache using the search box on the left section of WHM
  2. Click to open it then click EasyApache (ApacheUpdate) option
  3. This will open the present time Apache Configuration Profile
  4. Click the gear icon for a customized profile option
  5. You will see Apache wizard guiding you through various steps
  6. Here, select the Apache version
  7. Then, select your PHP versions
  8. Next, from the Short Options List, select the features you like to include in your Apache
  9. You can enable the modules you like to add and you can also disable the modules which you don’t want
  10. For more configuration options you may click the Exhaustive Options List
  11. Finally, select the Save and Build option

In the Exhaustive Options List, you can select or deselect various other modules. There is also an option called Save Only that only saves your profile and doesn’t starts the building process.

To start building you will need to click Save and Build option as explained above. Once you click this option, do not close your browser window and wait for the process to complete.

This may take some time depending on the options you have selected and the power of your server. If you are using a small server with limited resources then you should not enable many options at once and instead enable a few options first and then repeat the process for enabling more modules.

How To Configure PHP Directives On Your Server?

PHP allows you to control different aspects of your websites by using directives in php.ini files. These files contain the default configuration for the operation of PHP applications.

By using PHP directives you can control different variables such as upload size, file timeout, and resource limit, etc of websites running on your hosting, VPS, or dedicated server.

To add or edit a PHP directive – Log in to your SANGKRIT.net account and follow these steps:

  1. Open cPanel of your server or hosting option
  2. Navigate to the File Manager interface via cPanel -> Home -> Files -> File Manager
  3. Make sure that hidden files are visible to you or you can enable them via Settings, by ticking the Show hidden files checkbox option
  4. Navigate to the target directory.
  5. Create a new file – click New File / + File button
  6. Enter .user.ini filename
  7. Click Create New File button
  8. Select the new file from the list of files and click Edit
  9. Now enter the PHP directives you wish to adjust for the present directory
  10. Click the Save button

INI files can be configured on per-directory basis and are processed only by the CGI/FASTCGI SAPI. This functionality obsoletes the PECL htscanner extension. If you are running PHP as an Apache module then the .htaccess file will do your thing.

In addition to the main INI file, PHP scans each directory for its INI file. In a case where the PHP file has been kept outside the document root, only its directory is scanned.

Easily Add/Remove WWW From WordPress Admin Area

Now you can configure WordPress to always or never use www. in all internal links on your website. By default this setting is configured from domain management page. But in this lesson we will show you how you can change this setting from your admin area dashboard.  Continue reading Easily Add/Remove WWW From WordPress Admin Area

How To Install & Configure phpMyAdmin On Ubuntu 12.04 & Greater Versions?

phpMyAdmin is a free software that provides you a user friendly interface to work with MySQL on the web. It simply provides you a convenient visual frontend to access MySQL capabilities. This tutorial shows you the steps for installing phpMyAdmin on Ubunu Linux so before installing it make sure you must have root privileges on your virtual private server.

Continue reading How To Install & Configure phpMyAdmin On Ubuntu 12.04 & Greater Versions?

Different Ways Of Increasing PHP Memory Limit When Using WordPress

Increasing PHP limit is easy. The most popular method of increasing PHP limit is by editing the PHP.ini file which is present on your site’s root directory. But here are few more menthods you can use for increasing PHP memory limit in your WordPress site.

Continue reading Different Ways Of Increasing PHP Memory Limit When Using WordPress

How To Restrict Other Servers From Accessing Your Files ?

If your site stores popular image files then for reducing bandwidth usage you can use this Apache hack for denying servers to access your files. Open your sites .htaccess file for editing and add the following code:

<FilesMatch “.(gif|jpe?g)$”>
SetEnvIf Referer “^http://([^/]*.)?mydomain.com/” request_ok = 1
Order Allow, Deny
Allow from env=request_ok
</FilesMatch>

This restricts other domains form accessing all GIF or JPG files in  your website.

How To Configure Apache WebSite To Use Multiple Ports ?

  1. Open httpd.conf file in your host.
  2. Find Listen 80 and on the next line add Listen 8080
  3. Find VirtualHost section for your Site config.
  4. Add *:8080. It should look like this: <VirtualHost *:80 *:8080>
  5. Restart Apache
  6. Test your work by hitting your site to the new port number. Example: http://www.yoursite.com:8080

This would be helpful for you if your ISP is blocking any port. You can add an alternate port in your website. Here we have used port 8080 but you are free to use any other.

Creating Temporary And Permanent Redirects Using Apache

301 is a permanent redirect and 302 is a temporary redirect. 301 redirect is used when you want to redirect pages without penalizing them in search engines. And 302 redirect is used when you want to set up temporary redirect for keeping your page rank better in search engines. Learn more.

How To Set Up Permanent Redirect Using Apache ?

Open your site’s .htaccess file.

If there is no .htaccess redirect then create a new text file in your site’s root.

Add this line at the very end of your .htaccess file:

Redirect 301 /REDIRECT_PATH NEW_URL

Where:

REDIRECT_PATH = Directory path on your web server. And

NEW_URL = Is the path you want the pages redirected to.

Save the file and test your URL.

Example: 

Redirect 301 /tags/lamp/ https://www.sangkrit.net/tags/lamp/

How To Set Up Temporary Redirect Using Apache ?

Open your site’s .htaccess file.

If there is no .htaccess redirect then create a new text file in your site’s root.

Add this line at the very end of your .htaccess file:

Redirect 302 /REDIRECT_PATH NEW_URL

Where:

REDIRECT_PATH = Directory path on your web server. And

NEW_URL = Is the path you want the pages redirected to.

Save the file and test your URL.

Example:

Redirect 302 /tags/lamp/ https://www.sangkrit.net/tags/lamp/

Difference Between Permanent And Temporary Redirects

301 redirect is a permanent redirect whereas 302 is a temporary redirect. Permanent redirects tell search engines that old URL is out so that they can pull this new URL in it’s place. 301 is used when you want to preserve the page index and keep the page rank.