📜 ⬆️ ⬇️

[Arch Linux] Configuring a bunch of Apache, Nginx, PHP and Percona DB

After moving from Ubuntu to Arch, there was a need to configure this bundle, however, unlike Ubuntu, under Arch there wasn’t such a manual. Having collected ideas from various manuals, including those that were written under Ubuntu, and decided to write such a solid guide for Habr.

Just want to say that this is a basic installation, without virtual hosts in the number of n-pieces, just setting up for local development.

XAMPP didn't suit me just for ideological reasons.
')

So let's get started.



It is assumed that yaourt is already installed and you know how to use it at least a little, and also the execution of root commands from your user is set up (set sudo package, then uncomment the line "% wheel ALL = (ALL) ALL" in the file / etc / sudoers and relogin; when executing commands with sudo, we enter the password from our user, not from root).

Also, before installing directly, make sure that you have connected extra-and community-repositories.
For this:

sudo nano /etc/pacman.conf

And we check that the sections of these repositories look the same.

[extra]
#SigLevel = PackageOptional
Include = /etc/pacman.d/mirrorlist
[community]
#SigLevel = PackageOptional
Include = /etc/pacman.d/mirrorlist

And synchronize the package lists.

sudo pacman -Sy



First we install Apache and PHP and, accordingly, fix the configs a bit.


sudo pacman -S apache php-apache
yaourt mod-rpaf

Now we need to edit /etc/httpd/conf/httpd.conf: include 2 modules for apache - rpaf and php5, plus add configuration for rpaf and a few more details.

sudo nano /etc/httpd/conf/httpd.conf

  1. We change “Listen 80” to “Listen 81”, since port 80 will listen to nginx.
  2. Add 2 lines to the LoadModule section.
    LoadModule rpaf_module modules/mod_rpaf-2.0.so
    LoadModule php5_module modules/libphp5.so
  3. You can change the email in the “ServerAdmin” line, although this is an optional item. I usually change out of habit.
  4. Just below is the commented line "ServerName" - uncomment and replace with "ServerName 127.0.0.1:81"
  5. We check that the "TypesConfig conf / mime.types" line is not commented out in the "<IfModule mime_module>" section
  6. Let's also comment on the line “MIMEMagicFile conf / magic”
  7. In the section "<IfModule dir_module>" we replace the line with the parameter "DirectoryIndex" to the following form:
    DirectoryIndex index.php
  8. And finally, at the end of the file we add.
    Include conf/extra/php5_module.conf
    RPAFenable On
    RPAFproxy_ips 127.0.0.1 10.0.0.1
    RPAFsethostname On
    RPAFheader X-Forwarded-For


Save the file (Ctrl + O) and exit (Ctrl + X).

Now we have the second Apache configuration file left a little bit to change.

sudo nano /etc/httpd/conf/ports.conf

Change "Listen 80" to "Listen 81".

On this with the setting of Apache, we are finished. Go to PHP.


sudo nano /etc/php/php.ini

  1. Customize “post_max_size”. Usually, 60M is quite enough, and even a lot less - look at the situation. Similarly, we configure “upload_max_filesize” and “max_file_uploads”.
  2. Turn on the modules. There can be no single solution, but my option for most needs should be enough ( http://pastebin.com/cZwepL0T ). If any additional modules are needed that are not in the list, first of all we are looking at yaourt.
  3. I advise you to uncomment and configure "date.timezone" ( http://php.net/date.timezone ).
  4. Uncomment the line “session.save_path =„ / tmp “.


Save the file (Ctrl + O) and exit (Ctrl + X).

Restart apache.
sudo rc.d restart httpd

Next to check create a file index.php. (Here we enter the password not from our user, but from root.)

su -c "echo '<?php phpinfo(); ?>' > /srv/http/index.php"

After that, if you go to http: // localhost: 81 / , you should see a page with full information about PHP and Apache. Something like that.



Moving on to installing and configuring NGINX


Install the latest (dev-branch) version. If you want a stable one, simply write „sudo pacman -S nginx“ instead of the command below.

yaourt nginx-devel

And we will bring the config view to the following form.

sudo nano /etc/nginx/conf/nginx.conf

Erase everything and copy everything from here - http://pastebin.com/2S8KnqkH .

And restart nginx.

sudo rc.d restart nginx

Now, you can go on port 80 and you should also see information about php, as it was before ( http: // localhost ).

And the last step - installing PerconaDB


As you know, MySQL itself is far from being the smartest database, so I usually install a fork - PerconaDB. In more detail about features you can read on the official site , from myself unless I can say that MySQL has backward compatibility, so there will be no unexpected problems.

sudo pacman -S percona-server

And set up a password for the administrative user PerconaDB.

mysql_secure_installation

That's how we got a fairly smart config of the local web server. I hope this topic will be useful to someone.



ps if there are any suggestions for improving the material - write in the comments.
pps does not leave me feeling that the section "gzip_types" in the nginx config is not quite optimal - so I will also listen to the suggestions.

Forgot to write about autoloading services at OS startup


sudo nano /etc/rc.conf

And at the very bottom of the file in the array "DAEMONS" we add:

@nginx @httpd @mysqld

Source: https://habr.com/ru/post/140537/


All Articles